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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
    P.at(i)--;
  }
  for (int i = 0; i < N; i++) cin >> C.at(i);
  long long int ans = -1000000000000000000;
  
  for (int i = 0; i < N; i++) {
    int v = i;
    long long int cycle_sum = 0;
    int cycle_cnt = 0;
    while (true) {
      cycle_cnt++;
      cycle_sum += C.at(v);
      v = P.at(v);
      if (v == i) break;
    }
    long long int path = 0;
    int cnt = 0;
    while (true) {
      cnt++;
      path += C.at(v);
      if (cnt > K) break;
      int num = (K - cnt) / cycle_cnt;
      long long int score = path;
      if (cycle_sum > 0) score += cycle_sum * num;
      ans = max(ans, score);
      v = P.at(v);
      if (v == i) break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println(in.nextString().chars().filter(c -> c == '1').count());
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 28756
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        x: isize,
        n: usize,
        p: [isize; n],
    }
    let p = p.into_iter().collect::<HashSet<_>>();
    println!(
        "{}",
        (0..=101)
            .filter(|y| !p.contains(&y))
            .min_by_key(|&y| ((x - y).abs(), y))
            .unwrap()
    );
}


Measured memory_bytes: 2208
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll n, m;
    cin>>n>>m;
    ll x=n*m;
    cout<<x<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	map<pii, ll> mp;
	for (int i = 1; i <= n; i++) {
		string p = to_string(i);
		int s = p[0] - '0';
		int t = p[p.size() - 1] - '0';
		mp[pii(s, t)]++;
	}
	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ll a = mp[pii(i,j)];
			ll b = mp[pii(j,i)];
			ans += a * b;
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline


import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    t = 1
    for a in A:
        if a & 1:
            print(0)
            return
        else:
            t = lcm(t, a//2)
    for a in A:
        if t % a == 0:
            print(0)
            exit()

    ans = M//t/2
    ans = -(-ans//1)
    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16268
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	ll sum[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sum[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
	{
		sum[i]=sum[i+1]%MOD+a[i]%MOD;
		sum[i]%=MOD;
	}
	ll ans=0;
	for(int i=0;i<n-1;i++)
	{
		ans+=(a[i]*sum[i+1])%MOD;
		ans%=MOD;
	}
	cout<<ans%MOD;
	return 0;
}

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

using namespace std;

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

    int n,m;
    cin >>n>>m;
    //for(int i=0;i<n;i++) scanf("%d",&m[i]);
    n==m ? printf("%d",n+m):printf("%d",2*max(n,m)-1);
    return 0;
}

Measured memory_bytes: 256
n = input()
p = input().split(" ")
for i, pp in enumerate(p):
    p[i] = int(pp)
count = 0
for i in range(len(p)-2):
    mirutoko = p[i:i+3]
#     print(mirutoko)
    mirutoko_sort = sorted(mirutoko)
#     print(mirutoko_sort)
    if mirutoko[1] == mirutoko_sort[1]:
        count += 1
#     print(count)
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,x,a[100000],b[100000],ans;
  cin >> n >> x;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[i]=abs(x-a[i]);
  }
  sort(b,b+n);
  ans=b[0];
  for(int i=1; i<n; i++) {
    ans=__gcd(ans,b[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
def main():
    n = int(input())

    ans = 0
    for i in range(n):
        x,u = map(str,input().split())
        x = float(x)
        if u == 'JPY':
            ans += x
        else:
            ans += x * 380000
    print(ans)


if __name__ == '__main__':
    main()


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

ll dfs(ll h, ll k) {
    if (h == 1) {
        return k;
    }
    return dfs(h / 2, k * 2) + k;
}

int main() {
    ll H;
    cin >> H;
    cout << dfs(H, 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl0

ll modpow(ll x, ll y, ll m){
    if(y==0) return 1;
    ll res = modpow(x,y/2,m);
    return res * res % m * (y&1 ? x : 1) % m;
}

int h,w,n,k;

int ask(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c-1, d-1);
    fflush(stdout);
    int p;
    cin >> p;
    return p;
}

int ans[50][50];

void solve(int i1, int j1, int i2, int j2, int n){
    int h = i2 - i1;
    int w = j2 - j1;
    if(n == 0 || n == h*w){
        for(int i = i1; i < i2; ++i){
            for(int j = j1; j < j2; ++j){
                ans[i][j] = n == 0 ? 0 : 1;
            }
        }
    } else {
        if(w == 1 || rand()%2){
            int x = ask(i1, j1, i1 + h/2, j2);
            solve(i1, j1, i1 + h/2, j2, x);
            solve(i1 + h/2, j1, i2, j2, n - x);
        } else {
            int x = ask(i1, j1, i2, j1 + w/2);
            solve(i1, j1, i2, j1 + w/2, x);
            solve(i1, j1 + w/2, i2, j2, n - x);
        }
    }
}

int main(){
    srand(time(0));
    cin >> h >> w >> n >> k;
    memset(ans, -1, sizeof ans);
    solve(0, 0, h, w, n);

    // rep(i,h){
    //     rep(j,w){
    //         cerr << ans[i][j];
    //     }
    //     cerr << endl;
    // }

    ll sigma = 0;
    rep(i,h)rep(j,w){
        sigma += ans[i][j] * modpow(2, i*w + j, k);
        sigma %= k;
    }
    cout << "! " << sigma << endl;
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    string S;
    cin >> S;
    cout << count(S.begin(), S.end(), '+') - count(S.begin(), S.end(), '-') << endl;

    return 0;
}

Measured memory_bytes: 256
import collections

if __name__ == '__main__':
    n, m = map(int, input().split())
    l = [list(map(int, input().split())) for i in range(m)]

    ways = [[] for i in range(n+1)]

    for i in l:
        ways[i[0]].append(i[1])
        ways[i[1]].append(i[0])

    #print(ways)

    q = collections.deque()

    ans = [-1] * n # 道案内
    ans[0] = 0

    q.append(1)

    while(len(q) != 0):
        item = q.popleft()
        for i in ways[item]:
            if ans[i-1] == -1:
                ans[i-1] = item
                q.append(i)
                #print(ans , i , item)

    if -1 in ans:
        print("No")
    else:
        print("Yes")
        for i in range(1,n):
            print(ans[i])


Measured memory_bytes: 57788
def INT(): return int(input())


def main():
    N = INT()
    count = 0

    for i in range(N):
        if len(str(i+1)) == 1 or len(str(i+1)) == 3 or len(str(i+1)) == 5:
            count += 1

    print(count)

if __name__ == '__main__':
    main()


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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

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

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 2 * 1e5;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int dp[maxn][4], h[maxn][4], n;

int f(int id, int m)
{
    if (id == n)
        return 0;

    if (dp[id][m] != -1)
        return dp[id][m];

    int res = 0;
    for (int i = 1; i <= 3; ++i)
        if (i != m)
            res = max(res, h[id][i] + f(id + 1, i));

    return dp[id][m] = res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 1; j <= 3; ++j)
            cin >> h[i][j];
 
    cout << f(0, 0);
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> Pi;
typedef long long int lld;
struct SegmentTree
{
  static const int INF = 1 << 30;
  
  vector< int > small, big, sum, add;
  int sz;
  
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    small.assign(2 * sz - 1, INF);
    big.assign(2 * sz - 1, -INF);
    sum.assign(2 * sz - 1, 0);
    add.assign(2 * sz - 1, 0);
  }
  inline void Merge(int k)
  {
    small[k] = min(small[2 * k + 1] + add[2 * k + 1], small[2 * k + 2] + add[2 * k + 2]);
    big[k] = max(big[2 * k + 1] + add[2 * k + 1], big[2 * k + 2] + add[2 * k + 2]);
    sum[k] = sum[2 * k + 1] + add[2 * k + 1] + sum[2 * k + 2] + add[2 * k + 2];
  }
  inline int RangeMaximumQuery(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return(-INF);
    if(a <= l && r <= b) return(big[k] + add[k]);
    int L = RangeMaximumQuery(a, b, 2 * k + 1, l, (l + r) >> 1);
    int R = RangeMaximumQuery(a, b, 2 * k + 2, (l + r) >> 1, r);
    return(max(L, R) + add[k]);
  }
  inline int RangeMinimumQuery(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return(INF);
    if(a <= l && r <= b) return(small[k] + add[k]);
    int L = RangeMinimumQuery(a, b, 2 * k + 1, l, (l + r) >> 1);
    int R = RangeMinimumQuery(a, b, 2 * k + 2, (l + r) >> 1, r);
    return(min(L, R) + add[k]);
  }
  inline int RangeSumQuery(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return(INF);
    if(a <= l && r <= b) return(sum[k] + add[k]);
    int L = RangeSumQuery(a, b, 2 * k + 1, l, (l + r) >> 1);
    int R = RangeSumQuery(a, b, 2 * k + 2, (l + r) >> 1, r);
    return(L + R + add[k]);
  }
  void RangeAdd(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      add[k] += x;
      return;
    }
    RangeAdd(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    RangeAdd(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    Merge(k);
  }
 
  void Update(int k, int x)
  {
    k += sz - 1;
    small[k] = big[k] = sum[k] = x;
    while(k > 0) {
      k = (k - 1) >> 1;
      Merge(k);
    }
  }
  int RangeMaximumQuery(int a, int b)
  {
    return(RangeMaximumQuery(a, b, 0, 0, sz));
  }
  int RangeMinimumQuery(int a, int b)
  {
    return(RangeMinimumQuery(a, b, 0, 0, sz));
  }
  int RangeSumQuery(int a, int b)
  {
    return(RangeSumQuery(a, b, 0, 0, sz));
  }
  void RangeAdd(int a, int b, int x)
  {
    return(RangeAdd(a, b, x, 0, 0, sz));
  }
};

int n,d;
Pi star[200000];
SegmentTree X(200010),Y(200010);

int main(){
  cin >> n >> d;
  for(int i=0;i<n;i++){
    cin >> star[i].second.first >> star[i].second.second >> star[i].first;
  }
  sort(star,star+n);
  for(int i=0;i<n;i++){
    X.Update(i,star[i].second.first);
    Y.Update(i,star[i].second.second);
  }
  int idx = 0;
  lld ans = -1;
  for(int i=0;i<n;i++){
    while(idx < n && star[idx].first - star[i].first <= d) idx++;
    lld maxx = X.RangeMaximumQuery(i,idx);
    lld minx = X.RangeMinimumQuery(i,idx);
    lld maxy = Y.RangeMaximumQuery(i,idx);
    lld miny = Y.RangeMinimumQuery(i,idx);
    ans = max(ans,(maxx-minx)*(maxy-miny));
  }
  cout << ans << endl;
}

Measured memory_bytes: 19880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
//#define local
//if you find any bug in my code, please tell me.
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,i,j,k,a[1010];
    ll ans=1;
    cin>>n;
    memset(a,0,sizeof(a));
    for(i=2; i<=n; i++)
        for(k=i,j=2; k>1; )
        {
            if(k%j==0) a[j]++,k/=j;
            else j++;
        }
    for(i=2; i<=n; i++)
        if(a[i]) ans=ans*(a[i]+1)%mod;
        cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String [] letters = new String[3];

        for (int i = 0; i < 3; i++) {
            letters[i] = input.readLine();
        }
        int current = 0;
        int [] positions = new int[3];
        while (true){
            if (positions[current] == letters[current].length()){
                System.out.println((char)(current + 'A'));
                break;
            }
            current = letters[current].charAt(positions[current]++) - 'a';

        }
    }
}



Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char const* argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll A, B, N;
	cin >> N >> A >> B;
	if ((A - B) % 2 == 0) {
		cout << abs(A - B) / 2;
		return 0;
	}
	else {
		if ((A + B) <= 2 * (N + 1) - (A + B)) {
			cout << (A + B - 1) / 2;
			return 0;
		}
		else {
			cout << (2 * (N + 1) - (A + B) - 1) / 2;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted([(x, i) for i, x in enumerate(A)], reverse=True)

m0, mi = B[0]
m1, _ = B[1]


for i in range(N):
    if i != mi:
        print(m0)
    else:
        print(m1)


Measured memory_bytes: 34048
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    if(i%3==0)cout << " " << i;
    else{
      int x=i;
      while(x){
        if(x%10==3){
          cout << " " << i;
          break;
        }
        x/=10;
      }
    }
  }
  cout << endl;
      
}



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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int main() {
    int h,a;
    cin >> h >> a;

    if(h%a ==0){
        ANS(h / a);
    }else{
        ANS(h / a + 1);
    }

    return 0;
}


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

int main()
{
    int N;
    cin>>N;
    vector<int>A(N);
    for(auto &i:A)
    cin>>i;
    int x,y,z;
    x=0;
    y=abs(A[1]-A[0]);
    for(int i=2;i<N;i++)
    {
        z=min(abs(A[i]-A[i-1])+y,abs(A[i]-A[i-2])+x);
        x=y;
        y=z;
    }
    cout<<y<<endl;
}

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

class Program {

    static int MX = 6;
    const int wht = 6, gry = 1, blk = 2;
    const long inf = long.MaxValue;

    static List<Edge> edges = null;
    static long[] d = null;




    class Edge {
        public int frm, to, cst;
        public Edge(int pf, int pt, int pc) {
            frm = pf;
            to = pt;
            cst = pc;
        }
        public string prt() {
            return "eg:" + frm.ToString() + "-" + to.ToString() + " " + cst.ToString();
        }
    }


    static bool shortestPath(int src) {

        for (int i = 0; i < MX; i++) {
            d[i] = inf;
        }
        d[src] = 0;

        int cnt = 0;
        bool updated = true;

        while (updated) {
            updated = false;
            foreach (var eg in edges) {
                if (d[eg.frm] != inf && d[eg.to] > d[eg.frm] + eg.cst) {
                    d[eg.to] = d[eg.frm] + eg.cst;
                    updated = true;
                    if (cnt == MX - 1) return false;
                }
            }
            cnt++;
        }
        return true;
    }

    static void Main(string[] args) {


        var inp = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
        int v, e; v = inp[0]; e = inp[1];

        MX = v;
        edges = new List<Edge>();
        d = new long[MX];


        for (int i = 0; i < e; i++) {
            var c = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            edges.Add(new Edge(c[0], c[1], c[2]));
        }


        bool ngCyc = false, tmp = false;
        string str = "";

        for (int i = 0; i < MX; i++) {
            tmp = shortestPath(i);
            if (!tmp) {
                ngCyc = true;
                break;
            }

            string s = "";
            foreach (var dst in d) {
                if (s.Length > 0) s += " ";
                s += dst == inf ? "INF" : dst.ToString();
            }
            str += s ;
            if (i < MX - 1) str += "\r\n";
        }

        //var exStdOut = new System.IO.StreamWriter("stdout.txt");
        //System.Console.SetOut(exStdOut);

        if (ngCyc) Console.WriteLine("NEGATIVE CYCLE");
        else Console.WriteLine(str);

    }
}




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

#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
ll ans=INT_MAX;
void solve(ll &n,ll &m,ll &x,vector<pair<ll,vector<ll> > > &points,vector<ll> store,ll index,ll price){
    
    ll fl=0;
    for(ll i=0;i<m;i++){
        if(store[i] < x){
            fl=1;
            break;
        }
    }
    if(!fl){
        ans=min(ans,price);
        return;
    }
    if(index == n){
        return;
    }
    solve(n,m,x,points,store,index+1,price);
    ll sm=price + points[index].first;
    for(ll i=0;i<m;i++){
        store[i] += (points[index].second)[i];
    }
    solve(n,m,x,points,store,index+1,sm);
}
int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   ll n,m,x;
   cin>>n>>m>>x;
   vector<pair<ll,vector<ll> > > points;
   ll c,p;
   for(ll i=0;i<n;i++){
       vector<ll> temp;
       cin>>c;
       for(ll j=0;j<m;j++){
           cin>>p;
           temp.pb(p);
       }
       points.pb(mp(c,temp));
   }
   ll index=0,price=0;
   vector<ll> store(m,0);
   solve(n,m,x,points,store,index,price);
   if(ans == INT_MAX){
       ans=-1;
   }
   cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//(double)clock() / CLOCKS_PER_SEC;
int ans[200009];
int ans2[200009];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vpii a(n+1);
    for(int i=1; i<=n; i++)
    {
        int x, y;
        cin>>x>>y;
        a[x]={y, i};
    }
    vector<bool> w(n+1, false);
    int mini=n;
    int last=0;
    for(int i=1; i<=n; i++)
    {
        w[a[i].F]=true;
        while(w[mini]) mini--;
        if(mini==n-i)
        {
            for(int j=i; j>last; j--)
            {
                ans[j]=(i-last);
            }
            last=i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        ans2[a[i].S]=ans[i];
    }
    for(int i=1; i<=n; i++) cout<<ans2[i]<<'\n';

    return 0;
}


Measured memory_bytes: 6348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long res = 0l;
		
		PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
		
		for (int i = 0; i < n; i++) {
			long cost = sc.nextLong();
			pq.offer(cost);
		}
		
		while (m > 0) {
			pq.add(pq.poll() / 2);
			m--;
		}
		
		while (!pq.isEmpty()) {
			res += pq.poll();
		}
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 47500
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,count=0;
  	cin>>n;
  	string s;
  	for(int i=1;i<=n;i++){
    	s=std::to_string(i);
      	if(s.size()%2==1){
        	count++;
        }
      	
    }
  	cout<<count<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut arr:Vec<usize> = (0..n).map(|_| read()).collect();
    let gap = {
        let mut gap = vec![];
        let mut x = 1 as usize;
        while x <= n{
            gap.push(x);
            x = x*3 + 1; // 間隔の決め方はx*3 + 1
        }
        gap.reverse(); // 大きい間隔を先に
        gap
    };
    let cnt = shell_sort(&mut arr, &gap[..]);
    println!("{}", gap.len());
    println!("{}", gap.iter()
        .map(|x| x.to_string())
        .collect::<Vec<String>>()
        .join(" "));
    println!("{}", cnt);
    for x in arr.iter() {
        println!("{}", x);
    }
}

fn insertion_sort(a: &mut Vec<usize>, gap:usize) -> usize {
    let mut cnt = 0;
    for i in gap..a.len() {
        let v = a[i];
        let mut j = i;
        while j >= gap && a[j-gap] > v {
            // a[j-gap]は0スタート(最初はj=gapで
            // 外側ループごとにjが増えていく)
            a[j] = a[j-gap]; // gap=3で1巡目なら、a[3] = a[3-3]
            j -= gap;
            cnt +=1;
        }
        a[j] = v; // a[3] = 0？
    }
    cnt
}

fn shell_sort(a: &mut Vec<usize>, gap: &[usize]) -> usize {
    let mut cnt = 0;
    for &i in gap.iter() {
        // 周回ごとに間隔を狭めていく
        cnt += insertion_sort(a, i);
    }
    cnt
}



Measured memory_bytes: 13216
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

int main() {
    int N, A[100050];
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];

    int B[100050];
    for (int i = 1; i <= N; i++) {
        B[A[i]] = i;
    }
    for (int i = 1; i <= N; i++) {
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
 #include<string.h>
 int main(){
 int n;
 char s[10010];
 scanf("%d%s",&n,s);
 int len=strlen(s);
 for(int i=0;i<len;i++){
 int x=s[i]-'A';
 x=(x+n)%26;
 putchar('A'+x);
 }
 putchar('\n');
 }

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1 << 24;

typedef unsigned long long ull;

int main(){
    int N, K;
    std::cin >> N >> K;

    int dp[110][5][5];
    REP(i, 110){
        REP(j, 5){
            REP(k, 5){
                dp[i][j][k] = 0;
            }
        }
    }
    
    int P[110];
    std::fill(P, P+110, 0);

    REP(i, K){
        int a, b;
        std::cin >> a >> b;

        P[a] = b;
    }

    if(P[1] == 0){
        dp[1][1][1] = 1;
        dp[1][2][1] = 1;
        dp[1][3][1] = 1;
    }else{
        dp[1][P[1]][1] = 1;
    }

    FOR(i, 2, N+1){
        if(P[i] != 0){
            //printf("Call: Day %d\n", i);
            dp[i][P[i]][2] = dp[i-1][P[i]][1];
            //dp[i][P[i]][3] = dp[i-1][P[i]][2];
            FOR(j, 1, 4){
                if(j == P[i]){continue;}
                FOR(k, 1, 3){
                    dp[i][P[i]][1] = (dp[i][P[i]][1] + dp[i-1][j][k]) % 10000;
                }
            }
        }else{
            FOR(j, 1, 4){
                FOR(k, 1, 3){
                    if(k >= 2){
                        dp[i][j][k] = dp[i-1][j][k-1];
                    }else{
                        FOR(l, 1, 4){
                            if(j == l){continue;}

                            //printf("Call: Day %d, Pasta %d L %d\n", i, j, l);
                            
                            dp[i][j][k] = (dp[i][j][k] + dp[i-1][l][1] + dp[i-1][l][2]) % 10000;
                        }
                    }
                }
            }
        }
    }

    // FOR(i, 1, N+1){
    //     printf("Day %d:\n", i);
    //     FOR(j, 1, 4){
    //         FOR(k, 1, 3){
    //             printf("%d ", dp[i][j][k]);
    //         }
    //         puts("");
    //     }
    // }

    int res = 0;
    FOR(i, 1, 4){
        FOR(j, 1, 3){
            res = (res + dp[N][i][j]) % 10000;
        }
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1172
#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>

#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
#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; }

#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, x; 
  cin >> N >> x;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = INF;
  REP(k, N){
    int ret = k*x;
    
    multiset<int> s;
    REP(i, k) s.insert((A[(N-1-i)%N]));
    REP(i, N){
      s.insert(A[i]);
      ret += *s.begin();
      s.erase(A[(N+i-k)%N]);
    }
    chmin(ans, ret);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = LS()
        r = 0
        for i in range(len(a)//2):
            if a[i*2][1] == a[i*2+1][1]:
                r += 1
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9056
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		int turn = 0;
		for (int i = 0; i < k; i++) {
			if (turn == 0) {
				a /= 2;
				b += a;
			} else {
				b /= 2;
				a += b;
			}

			turn ^= 1;
		}

		System.out.println(a + " " + b);

		sc.close();
	}

}


Measured memory_bytes: 23636
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int distance_ax = Math.abs(a-x);
		int distance_bx = Math.abs(b-x);
		
		if (distance_ax>=distance_bx){
			 System.out.println("B");	
		}else {
			 System.out.println("A");
		}
	}
}

Measured memory_bytes: 23124
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter
from itertools import product

def main():
    N = II()
    A = LI()
    n_neg = 0
    for a in A:
        if a < 0:
            n_neg += 1
        elif a == 0:
            n_neg = 0
            break
    if n_neg % 2 == 0:
        ans = sum(abs(a) for a in A)
    else:
        A = [abs(a) for a in A]
        A.sort()
        ans = sum(A[1:]) - A[0]

    return ans

print(main())

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

int main() {
    // #ifndef _DEBUG
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

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

    if (a+b+c >= 22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

bool dfs(vector<vector<char>>&cam, int s, int t) {
	int size = cam.size();
	int size1 = cam[s].size();
	int count = 0;
	for (int i = max(0, s - 1); 
		i< min(s + 2, size); i++) {
		if (cam[i][t] == '#') {
			count++;
		}
	}
	for (int i = max(t - 1, 0);
		i< min(t + 2,size); i++) {
		if (cam[s][i] == '#'&&i!=t) {
			count++;
		}
	}
	if (count >= 2) {
		return true;
	}
	else {
		return false;
	}
}
int main() {
	int n; 
	cin >> n;
	string s;
	cin >> s;
	vector<pair<int, int>>dir(s.size());
	int w = 0;
	int e = 0;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			w++;
		}
		else {
			e++;
		}
		dir[i].F = e;
		dir[i].S = w;
	}
	int ans = s.size();
	rep(i, s.size()) {
		int tmp = 0;
		tmp = dir[i].second + e - dir[i].first;
		if (s[i] == 'W') {
			tmp--;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main()
{
int h,w;
while(1)
{
cin>>h>>w;
if(h==0&&w==0)break;
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
if(i==0||i==h-1||j==0||j==w-1)cout<<"#";
else cout<<".";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}



Measured memory_bytes: 3012
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  val a = array(0)
  val b = array(1)
  if (a >= 13) {
    println(b)
  } else if (a >= 6 && a <= 12) {
    println(b / 2)
  } else {
    println(0)
  }
}


Measured memory_bytes: 27324
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int c;
    cin >> c;
    vector<int> S(n);
    vector<int> T(n);
    vector<int> C(n);
    for (int i = 0; i < n; ++i) {
        cin >> S[i] >> T[i] >> C[i];
        --C[i];
    }

    map<int,int> cnts;

    vector<vector<pair<int,int>>> P(c);

    for (int i = 0; i < n; ++i) {
        P[C[i]].emplace_back(S[i], T[i]);
    }
    for (auto& V : P) {
        sort(V.begin(), V.end());
    }

    for (auto& V : P) {
        int n = V.size();
        for (int i = 0; i < n; ++i) {
            int l = V[i].first;
            int r = V[i].second;
            while (i + 1 < n && V[i + 1].first == r) {
                r = V[++i].second;
            }
            cnts[l * 2 - 1] += 1;
            cnts[r * 2] -= 1;
        }
    }

    int res = 0;
    int sum = 0;
    for (auto& p : cnts) {
        sum += p.second;
        res = max(res, sum);
    }
   
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 11496
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;

int main(){
    int n;
    cin>>n;
    switch(n){
        case 1:
        cout<<"Hello World"<<endl;
        break;
        case 2:
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else if (i % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 10) % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 100) % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 1000) % 10 == 3) {
			cout << " " << i;
		}
	}
	cout << endl;
	return 0;
}

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

using namespace std;
 int a,m,n,b,kt[100009],dem=0;
 vector<int> a1[100009];
void bfs(int a)
{
    kt[a]=dem;
    for (int i:a1[a])
    {
        if (kt[i]==0) bfs(i);
    }
}
int main()
{
//freopen("tplt.inp","r",stdin);
//freopen("tplt.out","w",stdout);
    cin>>n>>m;
    for (int i=1;i<=100009;i++)
        kt[i]=0;
    for (int i=1;i<=m;i++)
    {
        cin>>a>>b;
        a1[a].push_back(b);
        a1[b].push_back(a);
    }
    for (int i=1;i<=n;i++)
    {
        if (kt[i]==0) {dem++;bfs(i);}
    }
    cout<<dem-1;
    return 0;
}


Measured memory_bytes: 9940
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
    IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,m,i,j;

    cin>>n>>m;
    int a[n+4][m+4]= {};
    char s[n+4][m+4]= {};

    for(i = 1; i < n+1; i++)
    {
        for(j = 1; j < m+1; j++)
        {
            cin>>s[i][j];
        }
    }
    for(i = 1; i < n+1; i++)
    {
        for(j = 1; j < m+1; j++)
        {
            if(s[i][j]=='#')
            {
                if(s[i][j-1]=='.')
                    a[i][j-1]++;
                if(s[i-1][j-1]=='.')
                    a[i-1][j-1]++;
                if(s[i-1][j]=='.')
                    a[i-1][j]++;
                if(s[i-1][j+1]=='.')
                    a[i-1][j+1]++;

                if(s[i][j+1]=='.')
                    a[i][j+1]++;
                if(s[i+1][j]=='.')
                    a[i+1][j]++;
                if(s[i+1][j+1]=='.')
                    a[i+1][j+1]++;
               if(s[i+1][j-1]=='.')
                    a[i+1][j-1]++;
            }
        }
    }
    for(i = 1; i < n+1; i++)
    {
        for(j = 1; j < m+1; j++)
        {
            if(s[i][j]=='.')
                cout<<a[i][j];
            else
                cout<<s[i][j];
        }
        cout<<endl;
    }


    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,m,l,r;
    cin>>n>>m>>l>>r;
    for(int i = 2; i <= m; i++){
        int a,b;
        cin>>a>>b;
        if(a>l)l=a;
        if(b<r)r=b;
        if(r<l){
            cout<<0;
            return 0;
        }
    }
    cout<<r-l+1<<endl;
return 0;
}

Measured memory_bytes: 256
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()
D = iInLV(N)

ans = len(list(set(D)))
print(ans)

Measured memory_bytes: 62352
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  a, b = map(int, input().split())
  x = a

  if b - a > 4:
    for y in range(a + 1, a + 5):
      x ^= y
      a += 1

      if x == 0:
        break

    a += ((b - a) // 4) * 4

  for y in range(a + 1, b + 1):
    x ^= y

  print(x, flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    vs f(h); cin>>f;
    vvl d(h,vl(w,0));
    rep(i,h)rep(j,w){
        if(f[i][j]=='#'){
            rep(v,8){
                ll ny=i+dy[v], nx=j+dx[v];
                if(ny<0 or nx<0 or ny>=h or nx>=w)continue;
                if(f[ny][nx]=='#')continue;
                d[ny][nx]++;
            }
        }
    }
    rep(i,h){
        rep(j,w)if(f[i][j]=='#')cout<<"#"; else cout<<d[i][j];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256