akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<vector<int>> vec(C, vector<int>(100010, 0));
  REP(i, N){
    int s, t, c;
    cin >> s >> t >> c;
    s--; t--; c--;
    vec[c][s]++; vec[c][t+1]--;
  }

  REP(i, C) REP(j, 100009){
    vec[i][j+1] += vec[i][j];
  }

  int ans = 0;
  REP(j, 100010){
    int ret = 0;
    REP(i, C){
      if(vec[i][j] >= 1) ret++;
    }
    chmax(ans, ret);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 24576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

bool solve(string s) {
  int mid = s.size() / 2;
  string a = s.substr(0, mid);
  string b = s.substr(mid);
  return a == b;
}

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

  int ans = 0;
  while(1) {
    s.pop_back();
    if(solve(s)) {
      ans = s.size();
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce


def gcd_list(numbers):
    return reduce(gcd, numbers)


def resolve():
    n, x = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    xxx = [abs(i-x) for i in xxx]
    print(gcd_list(xxx))
resolve()

Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
//int y[200000]={},z[200000]={};
int main()
{
    int cow=0;
string a;
cin>>a;
for(int i=0;a[i];i++)
    cow+=a[i]-'0';
    
if(cow%9)
    cout<<"No";
else
    cout<<"Yes";
}


Measured memory_bytes: 3748
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) a[i] = sc.nextInt();
		int now = 0;
		boolean[] isVisit = new boolean[N];
		Arrays.fill(isVisit, false);
		int ans = 0;
		while(true) {
			if(now == 1) break;
			if(isVisit[now]) break;
			isVisit[now] = true;
			now = a[now] - 1;
			ans++;
		}
		System.out.println((now == 1) ? ans : -1);
	}
}

Measured memory_bytes: 51004
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

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

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


void solve(){
    int n;
  cin >> n;
  //n/=2;
  int f = 0, t = 0;

  int count = 0;

    if(n%2==0){
        n/=2;
        for (int i = 5; n / i >= 1; i *= 5){
        //f++;
        count += n / i; 
        }
        cout << count << endl;
    }
    else{
        cout << 0 << endl;
    }
     
//cout << f << endl;
  //cout << count << endl;
  
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};



int main(){
	int n, in;
	int ans = -inf;
	vector<int> a;
	a.pb(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> in;
		if(!in) a.pb(i);
		if(a.size() > 1){
			ans = max(ans, a[a.size()-1] - a[a.size()-2]);
		}
	}
	ans = max(ans, n+1 - a[a.size()-1]);

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;


int main() {
	int N;
	cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    vector<int> dp(100010);
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        if (i == 1) dp[i] = dp[0] + abs(h[0] - h[1]);
        else {
            dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), 
                        dp[i-2] + abs(h[i-2]-h[i]));
        }
    }   

	cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}





Measured memory_bytes: 2028
import sys
s=input()
k=int(input())
l=[]
ct=1
ans=0
for i in range(1,len(s)):
  if s[i-1]==s[i]:
    ct+=1
  else:
    l.append(ct)
    ct=1
l.append(ct)
if len(l)==1:
  print((len(s)*k)//2)
  sys.exit()
for i in range(1,len(l)-1):
  ans+=l[i]//2
ans*=k
if s[0]==s[-1]:
  ans+=((l[0]+l[-1])//2)*(k-1)
  ans+=l[0]//2
  ans+=l[-1]//2
else:
  ans+=(l[0]//2)*k
  ans+=(l[-1]//2)*k
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k; i++)
    {
        if(c<=b){
            c *= 2;
            //cout << a << b << c << endl;
            continue;
        }
        if (b<=a){
            b *= 2;
            //cout << a << b << c << endl;
            continue;
        }
        
    }
    if(c>b&&b>a){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3628
// 2020-06-30 19:27:19
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct mint {
  ll divisor = 998244353;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
};
 
void answer() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<mint> dp(s+1, 0), p(s+1, 0);
  mint ans = 0;
  rep(i, n) {
    swap(p, dp);
    p[0] += 1;
    repc(j, s) {
      dp[j] = p[j];
      if(j - a[i] >= 0) dp[j] += p[j - a[i]];
    }
    ans += dp[s];
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int n, m, nxt[100005], batas, pos;
	char s[100005];
	vector<int> ans;
	scanf("%d %d %s", &n, &m, s);
	for (int i = 1; i <= n; i++)
		if (s[i] == '1') {
			batas = i + 1;
			while (s[batas] == '1')
				batas++;
			while (i < batas) {
				nxt[i] = batas;
				i++;
			}
		}
	pos = n;
	while (pos > 0) {
		batas = max(0, pos - m);
		if (s[batas] == '1')
			batas = nxt[batas];
		if (batas == pos) {
			puts("-1");
			return 0;
		}
		ans.pb(pos - batas);
		pos = batas;
	}
	while (ans.size()) {
		printf("%d", ans.back());
		ans.pop_back();
		if (ans.size())
			putchar(' ');
	}
	puts("");
	return 0;
}

Measured memory_bytes: 1020
n,m=map(int,input().split())
a = list(map(int, input().split()))

def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
keta=0
buf=b[0]
while(buf%2==0):
    buf/=2
    keta+=1
for i in range(n):
    buf=b[i]
    tmp=0
    while(buf%2==0):
        buf/=2
        tmp+=1
    if(keta!=tmp):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for (int i = 0; i < 1000; ++i) {
        int a[3] = {i/100, (i/10)%10, i%10};
        int process = 0;
        for (int j = 0; j < N; ++j) {
            if (process <= 2 && a[process] == (int)(S[j]-'0')) process++;
        }
        if (process == 3) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,m,l,r,mini,maxi;
    scanf("%d %d",&n,&m);
    mini=1;
    maxi=n;
    for(int i=0;i<m;i++){
        scanf("%d %d",&l,&r);
        mini=max(mini,l);
        maxi=min(maxi,r);
    }
    if(mini<=maxi){
        printf("%d\n",maxi-mini+1);
    }
    else{
        printf("0\n");
    }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> A(H);
  REP(i,H) cin >> A[i];

  int sy, sx;
  REP(i,H)REP(j,W) if(A[i][j] == 'S') {
    sy = i;
    sx = j;
  }

  queue<pair<int,int>> que;
  que.push(make_pair(sy * W + sx, 0));
  vector<vector<int>> flag(H, vector<int> (W, -1));

  while(!que.empty()) {
    pair<int,int> p = que.front();
    que.pop();
    if(p.second > K) continue;
    int y = p.first / W;
    int x = p.first % W;
    if(flag[y][x] != -1) continue;
    flag[y][x] = p.second;
    REP(k,4) {
      int yk = y + dy[k];
      int xk = x + dx[k];
      if(yk < 0 || yk >= H || xk < 0 || xk >= W) continue;
      if(A[yk][xk] == '#') continue;
      if(flag[yk][xk] != -1) continue;
      que.push(make_pair(yk * W + xk, p.second + 1));
    }
  }

  int res = INF;
  REP(i,H)REP(j,W) {
    if(flag[i][j] == -1) continue;
    int tmp = min(min(i, H - 1 - i), min(j, W - 1 - j));
    res = min(res, 1 + (tmp + K - 1) / K);
  }

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



Measured memory_bytes: 3584
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int x = sc.nextInt()-1;
        int y = sc.nextInt()-1;

        int[][] dist = new int[n][n];

        for (int i=0; i<n-1; i++) {
            for (int j=i+1; j<n; j++) {
                int tmpD = j-i;
                if (j<=x || y<=i) {
                    dist[i][j] = tmpD;
                } else {
                    if (i<=x) {
                        tmpD = Math.min(tmpD, x-i+1+Math.abs(j-y));
                        dist[i][j] = tmpD;
                    } else {
                        tmpD = Math.min(tmpD, i-x+1+Math.abs(j-y));
                        dist[i][j] = tmpD;
                    }
                }
//                } else {
//                    tmpD = Math.min(tmpD, x-i+1+y-j>0 ? x-i+y-x+y-j:tmpD);
//                    tmpD = Math.min(tmpD, x-i+j-y+1>0 ? x-i+j-y+1:tmpD);
//                    tmpD = Math.min(tmpD, i-x+1+y-j>0 ? i-x+1+y-j:tmpD);
//                    tmpD = Math.min(tmpD, i-x+1+j-y>0 ? i-x+1+j-y:tmpD);
//                    dist[i][j] = tmpD;
//                }
            }
        }

//        for (int i=0; i<n-1; i++) {
//            for (int j=i+1; j<n-1; j++) {
//                out.print(dist[i][j]);
//
//            } out.println(dist[i][n-1]);
//        }
//        out.flush();

        int[] ans = new int[n-1];

        for (int i=0; i<n-1; i++) {
            for (int j=i+1; j<n; j++) {
                if (dist[i][j]!=0) {
                    int tmp = dist[i][j]-1;
                    ans[tmp]++;
                }
            }
        }

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<n-1; i++) {
            sb.append(ans[i]+"\n");
        }



        out.print(sb.toString());
        out.flush();



    }

}


Measured memory_bytes: 53972
import itertools

n, m, q = map(int, input().split())
abcd_lis = []
for i in range(q):
    abcd = list(map(int, input().split()))
    abcd_lis.append(abcd)
L = []
for i in range(1, m+1):
    L.append(i)
H = list(itertools.combinations_with_replacement(L, n))
max_score = 0
for h in H:
    score = 0
    for j in range(q):
        if list(h)[abcd_lis[j][1]-1]-list(h)[abcd_lis[j][0]-1] == abcd_lis[j][2]:
            score += abcd_lis[j][3]
    if score > max_score:
        max_score = score
print(max_score)

Measured memory_bytes: 84912
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Text;
 
public class Program{
    public static void Main(){
        var watch = new Stopwatch();
        watch.Start();
        var isTest = false;
        var stream = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
        Console.SetOut(stream);
        TextReader reader;
        string filename="";
        if(filename.Length!=0){
            reader = new StreamReader(filename);
        }else{
            reader = Console.In;
        }
 
        var input = reader.ReadLine().Split().Select(int.Parse).ToArray();
        var x = input[0];
        var a = input[1];
        var b = input[2];
        if(b<=a){
            Console.WriteLine("delicious");
        }else if(b-a<=x){
            Console.WriteLine("safe");
        }else{
            //ずっと綴りを間違えていた
            Console.WriteLine("dangerous");
        }
 
 
        watch.Stop();
        if(isTest){
            Console.WriteLine($"実行時間{watch.ElapsedMilliseconds}ミリ秒");
        }
        Console.Out.Flush();
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
int main()
{
 int n,m,a,b,count=0;
  int c=1;
  scanf("%d %d" ,&n,&m);
  int d=n;
  for(int i=1;i<=m;i++)
  {
    scanf("%d %d",&a,&b);
    if(a>c)
      c=a;
    if(b<d)
      d=b;
  }
  if(c<=d){
  for(int i=c;i<=d;i++){
    count++;
      
  }
      
  }
  printf("%d",count);
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;
typedef pair<pi,pi> P;

const int INF=123456789;
int d[50][50];
int c[50][50][50][50];

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

void init()
{
    rep(i,50)rep(j,50)rep(k,50)rep(l,50) c[i][j][k][l]=INF;
}

int main()
{
    int w,h;
    while(scanf(" %d %d",&w,&h),w)
    {
        init();

        pi tk,kz;
        scanf(" %d %d", &tk.se, &tk.fi);
        scanf(" %d %d", &kz.se, &kz.fi);
        --tk.fi; --tk.se;
        --kz.fi; --kz.se;

        rep(i,h)rep(j,w) scanf(" %d", &d[i][j]);

        queue<P> que;
        que.push(P(tk,kz));
        c[tk.fi][tk.se][kz.fi][kz.se]=0;
        #define IN(x,y) (0<=x && x<w && 0<=y && y<h)
        while(!que.empty())
        {
            P now=que.front(); que.pop();
            pi a=now.fi, b=now.se;

            rep(i,4)
            {
                int ax=a.se+dx[i], ay=a.fi+dy[i];
                int bx=b.se+dx[i^2], by=b.fi+dy[i^2];

                if(!IN(ax,ay) || d[ay][ax]==1)
                {
                    ax=a.se;
                    ay=a.fi;
                }
                if(!IN(bx,by) || d[by][bx]==1)
                {
                    bx=b.se;
                    by=b.fi;
                }

                if(c[ay][ax][by][bx]>c[a.fi][a.se][b.fi][b.se]+1)
                {
                    c[ay][ax][by][bx]=c[a.fi][a.se][b.fi][b.se]+1;
                    que.push(P(pi(ay,ax),pi(by,bx)));
                }
            }
        }

        int ans=INF;
        rep(i,h)rep(j,w) ans=min(ans,c[i][j][i][j]);
        if(ans==INF) printf("NA\n");
        else printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 28256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

	ll n = 50LL;
	cout << n << endl;
	ll m = k%n;
	ll b = k/n;
	vl ans(n, n-1+b);
	rep(i, m) {
		ans[i] += n-(m-1);
	}
	REP(i, m , n) {
		ans[i] -= m;
	}
	
	rep(i, n) {
		if(i != 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


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

int main(){
  int A,B; cin >> A >> B;
  if (A == 1){
    A += 13;
  }
  if (B == 1){
    B += 13;
  }
  if (A < B){
    cout << "Bob" << endl;
  }else{
    if (A == B){
      cout << "Draw" <<endl;
    }else{
      cout << "Alice" <<endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll n;
    cin >> n;
    ll prev = 0;
    int flag = 0;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        if(i==0){
            prev = tmp - 1;
        }else{
            if(tmp > prev){
                prev = tmp - 1;
            }else if (tmp == prev){
                prev = tmp;
            }else{
                flag = 1;
                break;
            }
        }
    }
    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	int s[3][3],e[3][3],st,et,gt;
	for(int i=0;i<3;i++)
	{
		cin>>s[i][0]>>s[i][1]>>s[i][2]>>e[i][0]>>e[i][1]>>e[i][2];
	}
	for(int i=0;i<3;i++)
	{
		st=s[i][0]*3600+s[i][1]*60+s[i][2];
		et=e[i][0]*3600+e[i][1]*60+e[i][2];
		gt=et-st;
		cout<<gt/3600<<" "<<(gt%3600)/60<<" "<<(gt%3600%60)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
<?php
define('MOD', 10 ** 9 + 7);
list($k) = ints();
list($s) = strs();
$ls = strlen($s);
init($ls + $k - 1);
$pow25[0] = $pow26[0] = 1;
for ($i = 1; $i <= $k; ++$i) {
    $pow25[$i] = $pow25[$i - 1] * 25 % MOD;
    $pow26[$i] = $pow26[$i - 1] * 26 % MOD;
}
$ans = 0;
for ($i = 0; $i <= $k; ++$i) {
    $cnt = (nCr2($ls + $k - $i - 1, $ls - 1) * $pow25[$k - $i] % MOD) * $pow26[$i] % MOD;
    $ans = ($ans + $cnt) % MOD;
}
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($max)
{
    global $fac, $finv, $inv;
    $fac = $finv = [1, 1];
    $inv[1] = 1;
    for ($i = 2; $i <= $max; ++$i) {
        $fac[$i] = $fac[$i - 1] * $i % MOD;
        $inv[$i] = MOD - $inv[MOD % $i] * intdiv(MOD, $i) % MOD;
        $finv[$i] = $finv[$i - 1] * $inv[$i] % MOD;
    }
}

// 組み合わせ(前処理利用）
function nCr2($n, $r)
{
    global $fac, $finv;
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return $fac[$n] * ($finv[$r] * $finv[$n - $r] % MOD) % MOD;
}


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

typedef long long int ll;
ll k;

int main() {
    cin >> k;

    ll ans = 0;
    for(ll a = 1; a <= k; ++a) {
        for(ll b = 1; b <= k; ++b) {
            for(ll c = 1; c <= k; ++c) {
                ans += __gcd(__gcd(a, b), c);
            }
        }
    }

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

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#define endl "\n"
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

int main()
{

    long long a, b;
    cin >> a >> b;
    if(a% 2 != b % 2)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (a + b) / 2 << endl;
    }
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> ans;
    for (int i = 0; i < N; i++) {
        auto it = lower_bound(ans.rbegin(), ans.rend(), A[i]);
        if (it == ans.rbegin()) ans.push_back(A[i]);
        else *(it-1) = A[i];
    }
    cout << sz(ans) << '\n';
    return 0;
}

Measured memory_bytes: 4228
W,H,N = map(int,input().split())
XYA = [tuple(map(int,input().split())) for _ in range(N)]

xmin = 0
ymin = 0
xmax = W
ymax = H
for x,y,a in XYA:
  if a == 1:
    xmin = max(x,xmin)
  elif a == 2:
    xmax = min(x,xmax)
  elif a == 3:
    ymin = max(y,ymin)
  else:
    ymax = min(y,ymax)
#print(xmax,xmin,ymax,ymin)
print(max(xmax-xmin,0)*max(ymax-ymin,0))


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n;
vector<int> e[200005];

int dp[200005], dep[200005];

void dfs(int id, int pv){
	int fm = 0, sm = 0;
	for(auto nx: e[id]){
		if(nx != pv){
			dfs(nx, id);
			dp[id] = max(dp[id], dp[nx]);
			if(dep[nx] + 1 > fm){
				sm = fm;
				fm = dep[nx] + 1;
			}else if(dep[nx] + 1 > sm){
				sm = dep[nx] + 1;
			}
		}
	}
	dep[id] = fm;
	dp[id] = max(dp[id], fm + sm);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs(1, 0);
	int diam = dp[1] + 1; // #nodes on diam = length + 1
	if(diam % 3 == 2){
		printf("Second\n");
	}else{
		printf("First\n");
	}
	return 0;
}

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

int main(){
    long long x, y;
    cin >> x >> y;
    if(abs(x-y) <= 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
    return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> d(N);
   for (int i=0; i<N; i++){
      cin >> d.at(i);
   }
   sort(d.begin(), d.end());
   int cnt = 1;
   for (int i=0; i<N-1; i++){
      if (d.at(i) != d.at(i+1)){
         cnt++;
      }
   }
   cout << cnt << endl;
}



Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	long long ans(0), cur(0);
	for(int i(0); i < n; i++) {
		int x;
		scanf("%d", &x);
		if(x == 0) {
			ans += cur / 2;
			cur = 0;
		}else {
			cur += x;
		}
	}
	ans += cur / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php

$n = intval(trim(fgets(STDIN)));

$count=0.0;
$array = [];
for ($i=0; $i<$n; $i++) {
    $str = trim(fgets(STDIN));
    $sArr = str_split($str);

    sort($sArr);
    $newS = implode('', $sArr);

    if ( isset($array[$newS]) ) {
        // 出現済みなら出現回数を+1
        $array[$newS] += 1.0;

        // 出現済みの数を足す
        $count += $array[$newS];
    } else {
        // 一回現れたら保存
        $array[$newS] = 0.0;
    }
}

echo "$count\n";

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

int main(){
  long N,D;cin>>N>>D;
  vector<long> X(N),Y(N);
  for(int i=0;i<N;i++) cin>>X.at(i)>>Y.at(i);
  long U=D*D;
  int count=0;
  //long X,Y;
  for(int i=0;i<N;i++){
    long Q=(X.at(i)*X.at(i))+(Y.at(i)*Y.at(i));
  //  cout<<Q<<endl;
    if(Q<=U) count++;
  }
  cout<<count<<endl;
}


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

namespace ABC085_D___Katana_Thrower
{
    class Program
    {
        static void Main(string[] args)
        {
            var NH = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NH[0];
            var H = NH[1];
            var attack = new int[N];
            var throwing = new int[N];

            for (int i = 0; i < N; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                attack[i] = ab[0];
                throwing[i] = ab[1];
            }

            var attackMax = attack.Max();
            throwing = throwing.Where(s => s > attackMax).OrderByDescending(s => s).ToArray();

            var attackCount = 0;
            while (attackCount < throwing.Length && H > 0)
            {
                H -= throwing[attackCount];
                attackCount += 1;
            }
            if (H > 0)
            {
                attackCount += H / attackMax;
                if ((H % attackMax) > 0) attackCount += 1;
            }
            Console.WriteLine(attackCount);
        }
    }
}


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

int main(){
  long long A, B;
  cin >> A >> B;
  for(int i = 1; i <= B; i++){
    if((A * i) % B == 0){
      cout << A * i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
int main(){
	cin>>n;
	int op=1,f=0;
	rep(i,0,3){
		if(n/op%10==7){
			f=1;
			break;
		}
		op*=10;
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
    long long n;
    cin >> n;
    long long p = 2;
    long long ans = 0;
    long long count = 1;
    long long now = 0;
    while (n > 1) {
        if (n % p == 0) {
            n /= p;
            now ++;
            if (count == now) {
                ans ++;
                now = 0;
                count ++;
            }
        } else {
            if (p == 2) {
                p = 3;
            } else {
                p += 2;
            }
            if (p * p > n) {
                ans ++;
                break;
            } 
            count = 1;
            now = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
long long mod = 998244353;
long long power(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = power(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}
int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> fac(n + 1);
  fac[0] = 1;
  for(int i = 1;i < n + 1;i++)fac[i] = fac[i - 1] * i,fac[i] %= mod;
  ll divide = 0;
  divide = n - k - 1;
  ll res = 0;
  for(int i = divide;i <= n - 1;i++){
    ll now = 0;
    now = fac[n - 1] * power(fac[i],mod - 2),now %= mod;
    now *= power(fac[n - 1 - i],mod - 2),now %= mod;
    now *= m,now %= mod;
    now *= power(m - 1,i),now %= mod;
    res += now;
    res %= mod;
  }
  cout << res << endl;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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


int main( void )
{
	ll n;
	cin >> n;

	string s = "";
	while ( n > 0 ) {
		char tmp = n % 26;
		if ( tmp == 0 ) {
			tmp += 26;
		}
		s = (char)('a' + tmp - 1) + s;
		n = (n - 1) / 26;
//		cout << n << endl;
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
ll MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;
    if(abs(n-m)>=2){
        cout << 0 << endl;
        return 0;
    }else if(abs(n-m)==1){
        ll sum = 1;
        for (ll i = 1; i <= n;i++){
            sum *= i;
            sum %= MOD;
        }
        for (ll i = 1; i <= m;i++){
            sum *=i;
            sum %= MOD;
        }
        cout << sum % MOD << endl;
    }else{
        ll sum = 1;
        for (ll i = 1; i <= n; i++)
        {
            sum *= i;
            sum %= MOD;
        }
        for (ll i = 1; i <= m; i++)
        {
            sum *= i;
            sum %= MOD;
        }
        cout <<2* sum % MOD << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<b+min(a+b+1,c)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
  char s[4];
  scanf("%s",s);
  int num=700;
  if(s[0]=='o')num+=100;
  if(s[1]=='o')num+=100;
  if(s[2]=='o')num+=100;

  printf("%d\n",num);


  return 0;
}

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

A = list(map(int,input().split()))

S = [0]*N
S[0] = A[0]
S[1] = A[1]

for i in range(2,N):
    S[i] = S[i-2] + A[i]

if N%2 == 0:
    ans = max(S[-1],S[-2])
    for i in range(N):
        if i % 2 == 0:
            ans = max(ans,S[i]+S[-1]-S[i+1])
    
    print(ans)

else:
    M = A[0]
    for i in range(1,N//2+1):
        M = min(M,A[2*i])

    mss = - M
    s = - A[0]
    for i in range(N//2):
        s += A[2*i+1] - A[2*i+2]
        if s < 0:
            s = - A[2*i+2]
        elif mss < s:
            mss = s
        #print(i,mss)
    
    mss2 = - M
    t = - A[-1]
    for i in range(1,N//2+1):
        t += A[-2*i] - A[-2*i-1]
        if t < 0:
            t = - A[-2*i-1]
        elif mss2 < t:
            mss2 = t
    
    p = S[-2]
    for i in range(1,N):
        if i % 2 == 1:
            p = max(p,S[i]+S[-1]-S[i+1])
    
    print(max(S[-1]+mss,S[-1]+mss2,p))

###
#print(S)
#print(M)
###

Measured memory_bytes: 31592
N=int(input())
p=list(map(float, input().split()))
dp=[[0]*(N+1) for _ in range(N+1)]
dp[0][0]=1
for i in range(N):
    for j in range(N):
        dp[i+1][j+1]+=dp[i][j]*p[i]
        dp[i+1][j]+=dp[i][j]*(1-p[i])
print(sum(dp[N][N//2+1:]))

Measured memory_bytes: 252296
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;

void main()
{
	int n = readln.chomp.to!int;
	int[] p = new int[](n);
	foreach (ref v; p) {
		v = readln.chomp.to!int;
	}
	bool[] done = new bool[](n + 1);
	int[] memo = new int[](n + 1);
	foreach (v; p) {
		if (done[v - 1]) {
			memo[v] = memo[v - 1];
		} else {
			memo[v] = v;
		}
		done[v] = true;
	}
	int ans = 0;
	foreach (v; p) {
		ans = max(ans, v - memo[v]);
	}
	++ans;
	ans = n - ans;
	ans.writeln;
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


Measured memory_bytes: 5116
#include<stdio.h>

int main(){
	int N,ans=0;
	scanf("%d",&N);
	int p[N];
	for(int i=0;i<N;i++){
		scanf("%d",&p[i]);
		p[i]--;
	}
	for(int i=0;i<N;i++){
		if(p[i]==i){
			ans++;
			if(i<N-1){
				int tmp=p[i];
				p[i]=p[i+1];
				p[i+1]=tmp;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (l[i] == l[j]) continue;
        if (l[j] == l[k]) continue;
        if (l[k] == l[i]) continue;
        if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j])
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<sstream>
#include<map>
//#include<bits/stdc++.h>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

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

	priority_queue<long long, vector<long long>, greater<long long>> queue;
	for (int i = 1; i < 10; ++i) {
		queue.push(i);
	}
	long long x = 0;
	for (int i = 0; i < N; ++i) {
		x = queue.top();
		queue.pop();
		if (x % 10ll != 0) {
			queue.push(10ll * x + (x % 10) - 1);
		}
		queue.push(10ll * x + (x % 10));
		if (x % 10 != 9)queue.push(10ll * x + (x % 10) + 1);
		//cout << x << endl;
	}

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cmath>
int main(){
    long long int a,b,count=0;
    std::cin>>a;
    b=a;
    bool hantei[2000001]; // 十分大きなサイズを確保します
//     for (long long int i = 0; i<= 1000000; ++i) hantei[i]=false; // とりあえず全部ふるいに入れます
     for (long long int i = 2; i<= sqrt(a)+100000; ++i) {
         if (!hantei[i]) { // 素数 i を発見したら
             for (long long int j = i * 2; j <=sqrt(a)+100000; j += i) {
                 hantei[j]=true; // i の倍数をふるい落とす
             }
         }
     }
//    std::cout<<is_prime(0)<<std::endl;
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        long long int j=i;
        while(true){
            if(b==1||b<i){
                break;
            }
            if(b%j!=0)break;
            b=b/j;
            count++;
            j=j*i;
        }
    }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    for(long long int i=2;i<=sqrt(a)+100000;i++){
        if(!hantei[i]){
        if(b%i==0)b=b/i;
        }
    }
    if(b!=1 && a!=1&&count!=0)count++;
    if(count==0&&a!=1)count++;
    std::cout<<count<<std::endl;
    return 0;
}

Measured memory_bytes: 4700
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}

bool f(string s){
    rep(i,0,s.size()/2){
        if(s[i]!=s[s.size()-i-1])return false;
        
    }
    return 1;
}

signed main (){
    int n;cin>>n;
    vector<int> v(n);
    int sum=0,ans=0;
    map<int,int> mp;
    mp[0]++;
    rep(i,0,n){
        cin>>v[i];
        sum+=v[i];
        ans+=mp[sum];
        mp[sum]++;
    }
    cout<<ans<<endl;


    




}
/*
1-2
0.5-2

010
01110
00111
000000111
*/


Measured memory_bytes: 14336
solve ::Int -> Int -> Int -> Int
solve 0 _ a = a
solve n k a = min (solve n1 k (a + k)) (solve n1 k (a * 2))
  where
    n1 = n - 1

main :: IO ()
main = do
  n <- readLn :: IO Int
  k <- readLn :: IO Int
  print $ solve n k 1

Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var pl = new List<int[]>();
        for (var i = 0; n > i; i++)
        {
            pl.Add(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray());
        }

        Func<int, int, double>dist = (i, j) =>
        {
            double dx = pl[i][0] - pl[j][0];
            double dy = pl[i][1] - pl[j][1];
            return Math.Sqrt(dx * dx + dy * dy);
        };

        var sum = 0.0;
        for (var i = 0; n > i; i++)
        {
            for (var j = i + 1; n > j; j++)
            {
                sum += dist(i, j);
            }
        }
        Console.WriteLine(sum * 2 / n);

    }
}


Measured memory_bytes: 28364
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int Mod=998244353;
const int inv2=499122177;
int fpow(int a,int b)
{
	int ans=1,t=a;
	while(b)
	{
		if(b&1)ans=1ll*ans*t%Mod;
		t=1ll*t*t%Mod;
		b>>=1;
	}
	return ans;
}
void fwt(int* a,int n,int dft)
{
	for(int step=1;step<n;step<<=1)
		for(int i=0;i<n;i+=step<<1)
			for(int j=i;j<i+step;j++)
			{
				int x=a[j],y=a[j+step];
				a[j]=(x+y)%Mod;a[j+step]=(x-y+Mod)%Mod;
				if(dft==-1)a[j]=1ll*a[j]*inv2%Mod,a[j+step]=1ll*a[j+step]*inv2%Mod;
			}
	return ;
}
int f[300010],p[300010];
int main()
{
	int n;scanf("%d",&n);
	n=1<<n;
	int S=0;
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
		S+=p[i];
	}
	S=fpow(S,Mod-2);
	for(int i=0;i<n;i++)p[i]=1ll*p[i]*S%Mod;
	p[0]=(p[0]-1+Mod)%Mod;
	for(int i=1;i<n;i++)f[i]=Mod-1;
	f[0]=n-1;
	fwt(f,n,1);fwt(p,n,1);
	for(int i=1;i<n;i++)
		f[i]=1ll*f[i]*fpow(p[i],Mod-2)%Mod;
	f[0]=0;
	fwt(f,n,-1);
	int add=(Mod-f[0])%Mod;
	for(int i=0;i<n;i++)
		printf("%d\n",(f[i]+add)%Mod);
	return 0;
}

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

using  namespace std;

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

	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		string s = to_string(i);
		if (s.size() % 2 == 1) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
right_w = 0
right_E = 0
left_E = 0
left_W = 0
ans = len(s)
for i in s:
    if i == "W":
        right_w += 1
    else:
        right_E += 1
for i in range(len(s)):
    tmp = s[i]
    if tmp == 'W':
        right_w -= 1
        tmp_ans = left_W+ right_E
        if tmp_ans < ans:
            ans = tmp_ans
        left_W += 1
    else:
        right_E -= 1
        tmp_ans = left_W+ right_E
        if tmp_ans < ans:
            ans = tmp_ans
        left_E += 1
print(ans)

Measured memory_bytes: 3828