akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

const INF: i64 = 1e18 as i64 + 1;

fn main() {
    input!{
        N: usize,
        K: usize,
        mut A: [i64; N],
    }
    A.sort();
    let solve = |v| {
        let mut sum = 0;
        for left in 0..N {
            if A[left] < 0 {
                let mut ok = N as i64;
                let mut ng = -1;
                while (ok - ng).abs() > 1 {
                    let mid = ok + (ng - ok) / 2;
                    if A[left] * A[mid as usize] <= v {
                        ok = mid;
                    } else {
                        ng = mid;
                    }
                }
                sum += N as i64 - ok;
            } else {
                let mut ok = -1;
                let mut ng = N as i64;
                while (ok - ng).abs() > 1 {
                    let mid = ok + (ng - ok) / 2;
                    if A[left] * A[mid as usize] <= v {
                        ok = mid;
                    } else {
                        ng = mid;
                    }
                }
                sum += ok + 1;
            }
            if A[left] * A[left] <= v {
                sum -= 1;
            }
        }
        sum /= 2;
        sum >= K as i64
    };
    let mut ok = INF;
    let mut ng = -INF;
    while (ok - ng).abs() > 1 {
        let mid = ok + (ng - ok) / 2;
        if solve(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok);
}


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

#define REP(i,init, n) for(int i=init;i<n;i++)
#define REPE(i,init, n) for(int i=init;i<=n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    lli n, m;
    cin >> n >> m;
    lli small = 0;
    lli large = 100001;
    REP(i, 0, m) {
        lli l, r;
        cin >> l >> r;
        small = max(small, l);
        large = min(large, r);
    }
    if (large - small + 1 <= 0)
        cout << 0 << endl;
    else
        cout << large - small + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int n,b,a;
cin>>n>>a>>b;
a=n*a;
if(a==b){
    cout<<b;
}
if(a>b){
    cout<<b;
}
if(a<b){
    cout<<a;
}
 return 0;
}


Measured memory_bytes: 3564
n=int(input())
ab=[]
for _ in range(n):
  ab.append(list(map(int, input().split())))
absort=sorted(ab, key=lambda x:(x[1]))
now=0
for i in range(n):
  now+=absort[i][0]
  if now>absort[i][1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 117776
import java.io.*;
import java.util.*;

public class Main {
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        int[] x = in.ni(n);
        HashMap<Integer, Integer>[] map = new HashMap[m];
        for (int i = 0; i < m; i++) {
            map[i] = new HashMap<>();
        }
        for (int i = 0; i < n; i++) {
            int mod = x[i]%m;
            map[mod].put(x[i],(map[mod].containsKey(x[i])) ? map[mod].get(x[i])+1 : 1);
        }
        int[][] arr = new int[m][2];
        for (int i = 0; i < m; i++) {
            for(Integer j: map[i].keySet()){
                arr[i][0] += map[i].get(j);
                arr[i][1] += map[i].get(j)/2;
            }
        }
        long ans = 0;
        for (int i = 0; i <= m/2; i++) {
            if(i==0||i*2==m) ans += arr[i][0]/2;
            else {
                if(arr[i][0]>=arr[m-i][0]){
                    ans += arr[m-i][0];
                    ans += Math.min(arr[i][1],(arr[i][0]-arr[m-i][0])/2);
                }else{
                    ans += arr[i][0];
                    ans += Math.min(arr[m-i][1],(arr[m-i][0]-arr[i][0])/2);
                }

            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 63536
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

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

}


Measured memory_bytes: 3636
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
char key[]={"abcdefghijklmnopqrstuvwxyz"};
int main(){
    int n;
    while(cin>>n,n){
        string s; cin>>s;
        vector<pii>hoge;
        rep(i,n){
            pii t; cin>>t.first>>t.second;
            hoge.push_back(t);
        }
        reverse(all(hoge));
        rep(i,n){
            int a,b; a=hoge[i].first;
            b=hoge[i].second;
            --a;
            --b;
            int dif=abs((a)-(b));
            int c,d;
            c=s[a]+dif-'a';
            while(c>25)c-=26;
            d=s[b]+dif-'a';
            while(d>25)d-=26;
            s[a]=key[d];
            s[b]=key[c];
        }
        cout<<s<<endl;
    }
}

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

bool dbgflag = false;

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> towns(n, vector<int>(n, INF));
  vector<vector<int>> towns_init(n, vector<int>(n, INF));
  vector<pii> bridges(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    towns[a][b] = 0;
    towns[b][a] = 0;
    towns_init[a][b] = 0;
    towns_init[b][a] = 0;
    bridges[i] = pii(a, b);
  }
  for (int i = 0; i < n; i++) {
    towns[i][i] = 0;
    towns_init[i][i] = 0;
  }

  //Warshall-Floyd
  int cnt = 0;
  for (pii p: bridges) {
    towns[p.first][p.second] = INF;
    towns[p.second][p.first] = INF;
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          towns[i][j] = min(towns[i][j], towns[i][k] + towns[k][j]);
        }
      }
    }

    bool fl = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (towns[i][j] != 0) {
          cnt++;
          fl = true;
          break;
        }
      }
      if (fl) break;
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        towns[i][j] = towns_init[i][j];
      }
    }
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int S,W;
  scanf ("%d %d",&S,&W);
  if (S>=1&&S<=100&&W>=1&&W<=100)
  {
      if (W>S||W==S)
      {
          printf ("unsafe\n");
      }
      else
      {
          printf ("safe\n");
      }
  }
  return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;

int main()
{
  int64_t N, K, t, d;
  cin >> N >> K;
  vector<priority_queue<int64_t>> vpq(MAXN);
  for (int i = 0; i < N; i++)
  {
    cin >> t >> d;
    vpq[t].push(d);
  }
  priority_queue<pair<int64_t, int64_t>> pq;
  for (int i = 0; i < MAXN; i++)
  {
    if (vpq[i].empty())
      continue;
    pq.emplace(vpq[i].top(), 1);
    vpq[i].pop();
    while (vpq[i].size())
    {
      pq.emplace(vpq[i].top(), 0);
      vpq[i].pop();
    }
  }
  int64_t tmp = 0, ans = 0;
  priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq0, pq1;
  for (int i = 0; i < K; i++)
  {
    tmp += pq.top().first;
    if (pq.top().second)
      pq1.push(pq.top().first);
    else
      pq0.push(pq.top().first);
    pq.pop();
  }
  tmp += pq1.size() * pq1.size();
  ans = max(ans, tmp);
  while (pq.size())
  {
    if (pq.top().second)
    {
      tmp -= pq1.size() * pq1.size();
      if (pq0.empty())
      {
        cout << ans << endl;
        return 0;
      }
      tmp -= pq0.top();
      pq0.pop();
      tmp += pq.top().first;
      pq1.push(pq.top().first);
      tmp += pq1.size() * pq1.size();
    }
    ans = max(ans, tmp);
    pq.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 11872
d={
"0":"* = ****",
"1":"* =* ***",
"2":"* =** **",
"3":"* =*** *",
"4":"* =**** ",
"5":" *= ****",
"6":" *=* ***",
"7":" *=** **",
"8":" *=*** *",
"9":" *=**** "}
s=raw_input()
while True:
    s="0"*(5-len(s))+s
    for i in range(8):
        print "".join(d[c][i] for c in s)
    try:
        s=raw_input()
        print
    except EOFError:
        break

Measured memory_bytes: 4324
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

int main()
{
    speed();
    ll i,x,y,a,b,c,d,z,w;
    cin>>a>>b>>c>>d;
    if(a>0 && b>0 && c>0 && d>0)
    {
        x = max(a,b);
        y = max(c,d);
        cout<<(x*y)<<endl;
    }
    else
    {
        w = a*c;
        x = a*d;
        y = b*c;
        z = b*d;
        cout<<max({w,x,y,z})<<endl;
    }

return 0;
}



Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
const int M=500009,INF=100000000;
int n,i,j,q,l,r,a[M],f[M][20],dp[M][30];
char s[M];

int read()
{
	int x=0; char ch=getchar();
	while (ch<48 || ch>57) ch=getchar();
	while (ch>=48 && ch<=57) x=(x<<1)+(x<<3)+ch-48,ch=getchar();
	return x;
}

int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	for (i=1;i<=n;++i) a[i]=s[i]-96,dp[i][a[i]]=i+1;
	for (i=n;i;--i)
	{
		for (j=a[i]+1;j<27;++j)
			if (dp[i][j-1]) dp[i][j]=dp[dp[i][j-1]][j-1];
		if (dp[i][26]) dp[i][0]=dp[dp[i][26]][26];
		for (j=1;j<a[i];++j)
			if (dp[i][0]) dp[i][j]=dp[dp[i][0]][j];
		if (dp[i][0]) f[i][0]=dp[i][0];
	}
	for (i=1;i<19;++i)
		for (j=1;j<=n+1;++j) f[j][i]=f[f[j][i-1]][i-1];
	for (q=read();q;--q)
	{
		l=read(),r=read(),++r;
		for (i=18;~i;--i)
			if (f[l][i]<=r && f[l][i]) l=f[l][i];
		if (l==r) puts("Yes"); else puts("No");
	}
	return 0;
}

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



int main(void){
  int N, L;
  cin >> N >> L;
  int findapple = abs(L);
  for(int k = 2; k <= N; k++){
    findapple = min(findapple, abs(L + k - 1));
  }
  int findapplenum;
  for(int i = 1; i <= N; i++){
    if(findapple == abs(L + i - 1)){
      findapplenum = i;
    }
  }
  cout << (N * (N + 2 * L - 1)) / 2 - (L + findapplenum - 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int cost1, cost2;
	cost1 = min(a, b);
	cost2 = min(c, d);

	cout << cost1 + cost2 << endl;

}

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 inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int x,y,z;cin>>x>>y>>z;
    int ans=0;
    x-=z;
    while(1){
        x-=y;
        if(x>=z){
            x-=z;
            ans++;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    int a, b, c, sum;
    while (true)
    {
        cin >> a >> b >> c;
        sum = a + b;
        if (sum == -2 && c == -1)
        {
            break;
        }
        if (a == -1 || b == -1)
        {
            cout << "F" << endl;
        }
        else if (sum >= 80)
        {
            cout << "A" << endl;
        }
        else if (sum >= 65)
        {
            cout << "B" << endl;
        }
        else if (sum >= 50)
        {
            cout << "C" << endl;
        }
        else if (sum >= 30)
        {
            if (c >= 50)
            {
                cout << "C" << endl;
            }
            else
            {
                cout << "D" << endl;
            }
        }
        else
        {
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
const int MAX_H = 100;
int H, W;
char as[MAX_H][MAX_H];
bool remove_w[MAX_H];
bool remove_h[MAX_H];

void solve() {
    for (int h = 0; h < H; ++h) {
        int count = 0;
        for (int w = 0; w < W; ++w) if (as[h][w] == '.') count++;
        if (count == W) remove_w[h] = true;
    }
    for (int w = 0; w < W; ++w) {
        int count = 0;
        for (int h = 0; h < H; ++h) if (as[h][w] == '.') count++;
        if (count == H) remove_h[w] = true;
    }

    for (int h = 0; h < H; ++h) {
        if (remove_w[h]) continue;
        for (int w = 0; w < W; ++w) {
            if (remove_h[w]) continue;
            printf("%c", as[h][w]);
        }
        printf("\n");
    }
}

int main() {
    cin >> H >> W;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            cin >> as[h][w];
        }
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  string s;
  cin >> n >> s >> k;

  REP(i,n){
    if(s[i] == s[k-1]) cout << s[i];
    else cout << "*";
  }
  cout << endl;

  return 0;
}

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

x = [-float('inf')] * (n + 1)
x[0] = 0
l = [0] * (n + 1)
_c = [2,5,5,4,5,6,3,7,6]
c = dict()
for i in range(m):
    c[a[i]] = _c[a[i] - 1]

for i in range(1, n + 1):
    x_max = -float('inf')
    l_max = 0
    for digit in c.keys():
        left = i - c[digit]
        if left >= 0:
            tmp_x = digit * (10 ** l[left]) + x[left]
            tmp_l = l[left] + 1
            if tmp_x > x_max:
                x_max = tmp_x
                l_max = tmp_l

    x[i] = x_max
    l[i] = l_max
print(x[-1])


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
//---------------------------------------------------------------
int main(){
  ll N,K;
  cin>>N>>K;
  string ans="unsafe";
  if(N>K)ans = "safe";

  cout<<ans<<endl;


}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(int.Parse(sS[i])); }
            int iOut = 0;
            lstInp.Sort();
            iOut += lstInp[1];
            lstInp[1] -= 1;
            lstInp.Sort();
            iOut += lstInp[1];

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string s = NextString();
        Console.WriteLine(s.Substring(0,s.Length-8));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    for(ll b = 1; b <= 3500; b++)
        for(ll n = b; n <= 3500; n++)
            if((4 * n * b - N * b - N * n) != 0)
                if((N * n * b) % (4 * n * b - N * b - N * n) == 0)
                    if((N * n * b) / (4 * n * b - N * b - N * n) > 0) {
                        cout << (N * n * b) / (4 * n * b - N * b - N * n) << " " << b << " " << n << "\n";
                        return 0;
                    }

    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
graph = [[] for i in range(n + 1)]
flag = [False for i in range(n + 1)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].append([v, w])
    graph[v].append([u, w])
color = [None for i in range(n + 1)]
color[1] = 0
queue = collections.deque([1])
while queue:
    test = queue.popleft()
    flag[test] = True
    for i in graph[test]:
        if flag[i[0]] == True:
            continue
        queue.append(i[0])
        color[i[0]] = i[1] % 2 ^ color[test]
for i in range(n):
    print(color[i + 1])

Measured memory_bytes: 46480
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;

int n;
vector<int> G[10005];
int c[10005];
int d[10005];
int idx;
map<int, int> ranks;

void dfs(int x) {
  if(d[x]) return;

  d[x] = c[idx++];

  rep(i, G[x].size()) {
    dfs(G[x][i]);
  }
}

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

  cin >> n;

  rep(i, n-1) {
    int a, b;
    cin >> a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  rep(i, n) {
    cin >> c[i];
  }
  sort(c, c+n, greater<int>());

  dfs(0);
  long res = 0;
  rep(i, n-1) {
    res += c[n-i-1];
  }
  cout << res << endl;

  rep(i, n) {
    cout << d[i] << endl;
  }
}


Measured memory_bytes: 1280
from collections import deque
def bfs(edges,start):
    waiting = deque()
    done[start] = 2
    c = 1
    for n in edges[start]:
        done[n] = 1
        waiting.append(n)
    while len(waiting):
        cur_node = waiting.popleft()
        if done[cur_node] != 2:
            done[cur_node] = 2
            c += 1
            for n in edges[cur_node]:
                if done[n] != 2:
                    done[n] = 1
                    waiting.append(n)
    #print(done,c)
    return c 
N,M = [int(a) for a in input().split()]
edge = [[] for _ in range(N)] 
for _ in range(M):
    a,b = [int(a) for a in input().split()]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
done = [0]*N
ans = []
for i in range(N):
    if done[i]==0: ans.append(bfs(edge,i))
#print(ans)
print(len(ans)-1)

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int n;
    cin >> n;
    map<ll, ll> mp_even, mp_odd;

    irep(i, n) {
        int tmp; cin >> tmp;
        if(i % 2) {
            mp_even[tmp]++;
        } else {
            mp_odd[tmp]++;
        }
    }
    
    vector<pll> even, odd;

    for(auto mp : mp_even) {
        even.push_back(make_pair(mp.second, mp.first));        
    }

    for(auto mp : mp_odd) {
        odd.push_back(make_pair(mp.second, mp.first));        
    }
    
    sort(even.rbegin(), even.rend());
    sort(odd.rbegin(), odd.rend());

    if(even[0].second != odd[0].second) {
        cout << n - even[0].first - odd[0].first << endl; 
    } else {
        ll ans = 0;
        if(even[0].first == odd[0].first) {
            ans = n - even[0].first;
            ll tmp = 0;
            if(even.size() > 1) {
                tmp = max(tmp, even[1].first);
            }
            if(odd.size() > 1) {
                tmp = max(tmp, odd[1].first);
            }
            ans -= tmp;
        } else if (even[0].first > odd[0].first) {
            ans = n - even[0].first;
            if(odd.size() > 1) { 
                ans -= odd[1].first; 
            }
        } else {
            ans = n - odd[0].first;
            if(even.size() > 1) {
                ans -= even[1].first;
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 8824
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

D,G = II()
p,c = Line(D)

def dfs(point,p):
    if point<=0:
        return 0
    else:
        ret = []
        for i in range(D):
            if p[i]==0:
                continue
            q,mod = divmod(point,(i+1)*100)
            if mod ==0:
                num = q
            else:
                num = q+1
            if num <= p[i]:
                ret.append(num)
            else:
                temp = p[i]
                p[i] = 0
                ret.append(dfs(point-100*(i+1)*temp-c[i],p)+temp)
                p[i] = temp
        return min(ret)

print(dfs(G,p))

Measured memory_bytes: 56412
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [A,B,C] = lines[0].split(" ").map(v=>BigInt(v));
    if(A%2n==0n||B%2n==0n||C%2n==0n){
        console.log(0);
    }else{
        console.log(min(A*B,B*C,A*C).toString());
    }
});

min = (...a)=>{return a.reduce((a,b)=>a<b?a:b, a[0])};


Measured memory_bytes: 29948
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int x = sc.nextInt();
int h = x/3600;
int m = (x-h*3600)/60;
int s = x-h*3600-m*60;
System.out.println(h+":"+m+":"+s);
}
}

Measured memory_bytes: 26016
import sys
import math
import collections
from collections import deque
n = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

def com(m):
    return math.factorial(m) // (math.factorial(m - 2) * 2)



c = collections.Counter(a)
d = c.most_common()
max = 0
for i in range(len(d)):
    if d[i][1] < 2:
        break

    max += com(d[i][1])


for i in range(n):
    print(max - c[a[i]] + 1)






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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

vector<int> g[610];
double p[610],e[610];

int main(){
    int n,m; scanf("%d%d",&n,&m);
    rep(i,0,m){
        int a,b; scanf("%d%d",&a,&b); a--; b--;
        g[a].push_back(b);
    }
    p[0]=1; e[n-1]=0;
    rep(i,0,n-1)for(int nxt:g[i])p[nxt]+=p[i]/g[i].size();
    rrep(i,n-2,-1){
        for(int nxt:g[i])e[i]+=e[nxt]/g[i].size();
        e[i]+=1;
    }
    double ans=e[0];
    rep(i,0,n){
        int sz=g[i].size(); if(sz<=1)continue; 
        for(int nxt:g[i]){
            double add=p[i]*((sz*e[i]-sz-e[nxt])/(sz-1)+1)-p[i]*e[i];
            chmin(ans,e[0]+add);
        }
    }
    printf("%.12f\n",ans);
    return 0;
}

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

int main(){
  
  int N,M;
  cin >> N >> M;
  
  int maxL = 0;
  int minR = 10e6;
  for ( int i = 0; i < M; i++){
    int L, R;
    cin >> L >> R;
    
    if (maxL < L){
      maxL = L;
    }
    
    if (minR > R){
      minR = R;
    }
  }
  int count = 0;
  for (int i = 1; i <= N; i++){
    if( i >= maxL && i <= minR){
      count++;
    }
  }
  cout << count;
  return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	cout << "a ";
	if(a<b) cout << "< ";
	if(a==b) cout << "== ";
	if(a>b) cout << "> ";
	cout << "b" << endl;
	
	
	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			int[] array = new int[N];
			int[] cntArray = new int[N];
			for (int i = 0; i < N; i++) {
				array[i] = scanner.nextInt();
			}

			int max = 0;
			int tmp = 0;
			for (int i = 0; i < N - 1; i++) {
				if (array[i] >= array[i + 1]) {
					tmp++;
					if (max < tmp) {
						max = tmp;
					}
				} else {
					tmp = 0;
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 58828
#include <stdio.h>
using namespace std;

int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H==0||W==0)break;
        for(int h=1;h<=H;h++){
            for(int w=1;w<=W;w++){
                if(h%2==1){
                    if(w%2==1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else{
                    if(w%2==1){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2592
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

def func(a,b):
    return max(len(str(a)),len(str(b)))
ans = 10**10
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans,func(i,n//i))

print(ans)

Measured memory_bytes: 39024
#include <iostream>
#include <iomanip>
using namespace std;
const int N = 3005;
double dp[N][N];
int vis[N][N];
double p[N];
int n;
double solve(int i, int chead, int ctail) {
	if ( i == n) {
		if ( chead > ctail) return 1;
		return 0;
	}
	if (vis[i][chead]) return dp[i][chead];
	double head = solve(i + 1, chead + 1, ctail) * p[i];
	double tail = solve(i + 1, chead, ctail + 1) * ( 1 - p[i]);
	vis[i][chead] = 1;
	return dp[i][chead] = head + tail;

}
int  main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	cout <<setprecision(10) << solve(0, 0, 0);
	return 0;
}


Measured memory_bytes: 104960
#include<cstdio>
#include<vector>

#define	mp			make_pair
#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	vector<int>		vi;
typedef	vector<vi>		vvi;
typedef	pair<int,int>	pii;

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

int main(){
	for(int hpinit,hpmax;scanf("%d%d",&hpinit,&hpmax),hpinit;){
		int m,n,tmp;	scanf("%d%d",&m,&n);

		vvi trap(m,vi(n));
		{
			char a[100][101];
			rep(i,m)	scanf("%s",a+i);
			int tmp;	scanf("%d ",&tmp);
			int f[128];
			rep(i,tmp){
				char ch;
				int dmg;	scanf("%c%d ",&ch,&dmg);
				f[ch]=dmg;
			}
			rep(i,m)rep(j,n)	trap[i][j]=f[a[i][j]];
		}

		scanf("%d ",&tmp);
		vector<pii> step(tmp);
		rep(i,tmp){
			char ch;
			int d;	scanf("%c%d ",&ch,&d);
			char f[128];
			f['R']=0,f['U']=1,f['L']=2,f['D']=3;
			step[i]=mp(d,f[ch]);
		}
		step.pb(mp(1,0));	// dummy

		int psize;	scanf("%d",&psize);
		vi por(psize);
		rep(i,psize)	scanf("%d",&por[i]);

		vi cure(1<<psize);
		rep(i,1<<psize)rep(j,psize){
			if(i&(1<<j))	cure[i]+=por[j];
		}

		int x=0,y=0;
		vi hp(1<<psize);	hp[(1<<psize)-1]=hpinit;
		rep(t,step.size())rep(k,step[t].first){
			int dmg=trap[y][x];
			rep(i,1<<psize){
				if(hp[i]<=0)	continue;
				if(hp[i]<=dmg){
					rep(j,i){
						if((j&i)==j){	// stat j is a subset of stat i
							hp[j]=max(hp[j],min(hp[i]+cure[i&~j],hpmax)-dmg);
						}
					}
				}
				hp[i]-=dmg;
			}
			int dir=step[t].second;
			x+=dx[dir];	y+=dy[dir];
		}

		bool ok=false;
		rep(i,1<<psize) if(hp[i]>0){ ok=true; break; }
		puts(ok?"YES":"NO");
	}

	return 0;
}

Measured memory_bytes: 880
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}


signed main() {
	string s,t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == t[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
import sys
from heapq import heappush,heapify,heappop
input = sys.stdin.readline
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = [i + j for i in a for j in b]
d.sort(reverse=1)
c.sort(reverse=1)
q = [(-d[0] - c[0], 0, 0)]
for _ in range(k):
    v, s, t = heappop(q)
    print(-v)
    if t + 1 < z:
        heappush(q, (-d[s] - c[t + 1], s, t + 1))
    if t == 0 and s + 1 < x * y:
        heappush(q, (-d[s + 1] - c[0], s + 1, 0))

Measured memory_bytes: 152476
import sys
from collections import defaultdict, deque

def main():
    input = sys.stdin.readline
    N = int(input())
    d = defaultdict(list)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        d[u-1].append((v-1, w))
        d[v-1].append((u-1, w))

    dist = [0] * N
    q = deque()
    q.append((0, 0))
    visited = set()

    while len(q) > 0:
        q_ = deque()
        while len(q) > 0:
            node1, cost1 = q.popleft()

            dist[node1] = cost1
            visited.add(node1)

            for node2, cost2 in d[node1]:
                if node2 in visited:
                    continue

                q_.append((node2, cost1 + cost2))

        q = q_

    for d in dist:
        print(d % 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57628
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A, B, C;
        cin >> A >> B >> C;
        if (B - A == C - B)
        {
                cout << "YES" << endl;
        }
        else
        {
                cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String gomi=sc.nextLine();
		for(int j=0;j<n;++j){
			String a=sc.next();
			String b=sc.next();
			String[] a2=a.split("");
			String[] b2=b.split("");
			int sum_a=0,sum_b=0;
			for(int i=0;i<a2.length;++i){
				int num=1;
				if(a2[i].matches("[2-9]")){ num=Integer.parseInt(a2[i]); i++; }
				if(a2[i].equals("m")) num*=1000;
				else if(a2[i].equals("c")) num*=100;
				else if(a2[i].equals("x")) num*=10;
				else if(a2[i].equals("i")) num*=1;
				sum_a+=num;
			}
			for(int i=0;i<b2.length;++i){
				int num=1;
				if(b2[i].matches("[2-9]")){	num=Integer.parseInt(b2[i]); i++; }
				if(b2[i].equals("m")) num*=1000;
				else if(b2[i].equals("c")) num*=100;
				else if(b2[i].equals("x")) num*=10;
				else if(b2[i].equals("i")) num*=1;
				sum_b+=num;
			}
			int ans=sum_a+sum_b;
			if(ans/1000>0){
				if(ans/1000!=1) System.out.print(ans/1000+"m");
				else System.out.print("m");
				ans-=ans/1000*1000;
			}
			if(ans/100>0){
				if(ans/100!=1) System.out.print(ans/100+"c");
				else System.out.print("c");
				ans-=ans/100*100;
			}
			if(ans/10>0){
				if(ans/10!=1) System.out.print(ans/10+"x");
				else System.out.print("x");
				ans-=ans/10*10;
			}
			if(ans/1>0){
				if(ans/1!=1) System.out.println(ans+"i");
				else System.out.println("i");
			} else {
				System.out.println();
			}
		}
	}
}



Measured memory_bytes: 67448
#include <iostream>

int main() {
  int debt = 100000;
  int weeks; std::cin >> weeks;
  for(int i=0; i<weeks; i++) {
    debt = debt*1.05;  
    debt = (debt+999)/1000*1000;
  }  
  std::cout << debt << std::endl; 
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std ;
typedef int Read ; // Here to change the type of numbers
inline Read Readin() {
	Read K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline Read Min( Read A , Read B ) { return A < B ? A : B ; }
inline Read Max( Read A , Read B ) { return A > B ? A : B ; }
inline Read Abs( Read A ) { return A < 0 ? -A : A ; }

char S[200005] ;
int main() {
	scanf( "%s" , S ) ;
	int N = strlen(S) ;
	long long B = 0 , Ans = 0 ;
	for(register int i = 0 ; i < N ; ++i )
		if( S[i] == 'B' ) ++B ;
			else Ans += B ;
	return not printf( "%lld\n" , Ans ) ;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  vll a_input(7);
  rep (i, 7) {
    scanf("%lld", &a_input[i]);
  }
  ll ai, ao, aj, al;
  ai = a_input[0];
  ao = a_input[1];
  aj = a_input[3];
  al = a_input[4];

  ll ans = 0;
  ans += ao;
  ans += (ai / 2 * 2);
  ans += (aj / 2 * 2);
  ans += (al / 2 * 2);
  if (ai == 0 || aj == 0 || al == 0) {
    printf("%lld\n", ans);
    return 0;
  }

  ll ans2 = 0;
  ans2 += ao;
  ans2 += 3;
  ans2 += ((ai-1) / 2 * 2);
  ans2 += ((aj-1) / 2 * 2);
  ans2 += ((al-1) / 2 * 2);

  printf("%lld\n", max(ans, ans2));

  return 0;
}


Measured memory_bytes: 888