akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Long();
            var ans = (1 + n) * n / 2 - n;
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



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

int main(){
  	int N, ans=1;
  	cin >> N;
  	string S[N];
  	for(int i=0; i<N; i++){
    	cin >> S[i];
      	//cout << S[i] << endl;
    }
  	sort(S, S+N);
  	for(int i=0; i<N-1; i++){
    	if(S[i]!=S[i+1]){
        	ans++;
        }
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 9884
#include<bits/stdc++.h>
  
using namespace std;
 
string S;
int idx;
int mp[256];
map< int, int > SS;
 
bool E()
{
  if(S[idx] == '0') {
    ++idx;
    return(0);
  }
  if(S[idx] == '1') {
    ++idx;
    return(1);
  }
  if(isalpha(S[idx])) {
    ++idx;
    return(mp[S[idx - 1]]);
  }
  if(S[idx] == '-') {
    ++idx;
    return(1 ^ E());
  }
  ++idx;
  bool F = E();
  bool isxor = S[idx] == '^';
  ++idx;
  bool G = E();
  ++idx;
  if(isxor) return(F ^ G);
  else return(F & G);
}
 
int tobit(const string& s)
{
  int bit = 0;
  S = s;
  for(int j = 0; j < (1 << 4); j++) {
    mp['a'] = (j >> 0) & 1;
    mp['b'] = (j >> 1) & 1;
    mp['c'] = (j >> 2) & 1;
    mp['d'] = (j >> 3) & 1;
    idx = 0;
    bit |= E() << j;
  }
  return(bit);
}
 
int main()
{
  vector< string > valid[17];
 
  int ret = 0;
   
  for(int i = 1; i <= 16; i++) {
    vector< string > vv;
    if(i == 1) {
      vv.emplace_back("0");
      vv.emplace_back("1");
      vv.emplace_back("a");
      vv.emplace_back("b");
      vv.emplace_back("c");
      vv.emplace_back("d");
    }
    for(auto& s : valid[i - 1]) {
      vv.emplace_back("-" + s);
    }
    int sz = i - 3;
    for(int k = 1; k < sz; k++) {
      int l = sz - k;
      for(auto&& s : valid[k]) {
        for(auto&& t : valid[l]) {
          vv.emplace_back("(" + s + "^" + t + ")");
          vv.emplace_back("(" + s + "*" + t + ")");
        }
      }
    }
    for(auto& s : vv) {
      int bit = tobit(s);
      if(!SS.count(bit)) {
        SS[bit] = i;
        valid[i].push_back(s);
      }
    }
  }
  string S;
  while(cin >> S, S != ".") cout << SS[tobit(S)] << endl;
}

Measured memory_bytes: 3908
#include<bits/stdc++.h>
#define mp(a, b) std::make_pair(a, b)
typedef std::pair<int, int> pii;
const int MAXN = 100000+10;
const int INF = 0x3f3f3f3f;
std::vector<int> G[MAXN];
int n, s, k;
int r[MAXN], l[MAXN];
std::priority_queue<pii> lq;
std::priority_queue<pii, std::vector<pii>, std::greater<pii> > rq;
int dfs(int x, int f){
    for(int i=0; i<G[x].size(); ++i){
        if(G[x][i]==f) continue;
        if(l[G[x][i]]<=l[x]-1) l[G[x][i]] = l[x]-1;
        else if(r[G[x][i]]>=l[x]+1) l[G[x][i]] = l[x]+1;
        else return 1;
        if(dfs(G[x][i], x))return 1;
    }
    return 0;
}
int main(){
//    freopen("t.in", "r", stdin);
    scanf("%d", &n);
    for(int i=1; i<=n; ++i){
        l[i] = -INF;
        r[i] = INF;
    }
    for(int i=1, u, v; i<n; ++i){
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    scanf("%d", &k);
    for(int i=1, v, p; i<=k; ++i){
        scanf("%d%d", &v, &p);
        l[v] = r[v] = p;
        s = v;
        lq.push(mp(p, v));
        rq.push(mp(p, v));
    }
    //for(int i=1; i<=n; ++i) printf("%d %d\n", l[i], r[i]);
    while(!lq.empty()){
        int x = lq.top().second;
        lq.pop();
        for(int i=0; i<G[x].size(); ++i){
            if(l[G[x][i]]<l[x]-1){
                /*if(l[G[x][i]]!=-INF){
                    printf("No\n");
                    return 0;
                }*/
                l[G[x][i]] = l[x]-1;
                lq.push(mp(l[x]-1, G[x][i]));
            }
        }
    }
    while(!rq.empty()){
        int x = rq.top().second;
        rq.pop();
        for(int i=0; i<G[x].size(); ++i){
            if(r[G[x][i]]>r[x]+1){
                /*if(r[G[x][i]]!=INF){
                    printf("No\n");
                    return 0;
                }*/
                r[G[x][i]] = r[x]+1;
                rq.push(mp(r[x]+1, G[x][i]));
            }
        }
    }
    for(int i=1; i<=n; ++i){
        //printf("%d %d\n", l[i], r[i]);
        if(r[i]<l[i]){
            printf("No\n");
            return 0;
        }
    }
    if(dfs(s, 0)){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    for(int i=1; i<=n; ++i) printf("%d\n", l[i]);
    return 0;
}


Measured memory_bytes: 13868
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long l[87] = {};
    l[1] = 1;
    l[0] = 2;
    long long ans = l[n];
    for(int i = 2; i <= n; i++){
        ans = l[i] = l[i-1] + l[i-2];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
def Fibonacci(n):
    if n == 0 or n == 1:
        dic[n] = 1
    if n in dic.keys():
        return dic[n]
    dic[n] = Fibonacci(n-1) + Fibonacci(n-2)
    return dic[n]

a = int(input())
dic ={}
print(Fibonacci(a))


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

using namespace std;

#define mem(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;

const int inf=0x3f3f3f3f;
const int maxn=1e4+5;
int n,m;
int p[]={0,2,5,5,4,5,6,3,7,6};
int vis[10];
int ans[maxn];
int lar,sma;
set<pii> st;
map<pii,bool> mt;

bool dfs(int res,int len) {
    if(res<sma*len) return false;
    if(lar*len<res) return false;
    if(st.find(mp(res,len))!=st.end()) return mt[mp(res,len)];
    if(len==1) {
        per(i,9,1) {
            if(vis[i]&&p[i]==res) {
                ans[len]=i;
                st.insert(mp(res,len));
                mt[mp(res,len)]=true;
                return true;
            }
        }
        st.insert(mp(res,len));
        mt[mp(res,len)]=false;
        return false;
    }
    per(i,9,1) {
        if(vis[i]&&dfs(res-p[i],len-1)) {
            ans[len]=i;
            st.insert(mp(res,len));
            mt[mp(res,len)]=true;
            return true;
        }
    }
    st.insert(mp(res,len));
    mt[mp(res,len)]=false;
    return false;
}

int main() {
    scanf("%d%d",&n,&m);
    rep(i,1,m) {
        int val;
        scanf("%d",&val);
        vis[val]=1;
    }
    int need=inf;
    sma=inf;
    lar=0;
    rep(i,1,9) {
        if(vis[i]) {
            need=min(need,p[i]);
            sma=min(sma,p[i]);
            lar=max(lar,p[i]);
        }
    }
    int len=n/need;
    while(!dfs(n,len)) {
        len--;
    }
    per(i,len,1) putchar('0'+ans[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top,S[1000];

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top+1];
}


int main(){
	int a,b;
	top = 0;
	char s[100];
	while ( scanf("%s", s) != EOF){
		if( s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(s[0] == '-'){
			b = pop();
			a = pop();
			push( a - b);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());	
	return 0;
}

Measured memory_bytes: 984
use std::collections::HashMap;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: u64 = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let mut b = vec![0; n + 1];

    for i in 0..n {
        b[i + 1] = b[i] + a[i];
    }
    for b_i in b.iter_mut() {
        *b_i %= m;
    }
    let mut map = HashMap::new();
    for b in b {
        *map.entry(b).or_insert(0) += 1;
    }
    let ans: u64 = map.iter().map(|(&_, &v)| (v * (v - 1)) / 2).sum();

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

int n,m,i,j;
vector <int> edge[100005];
bool vis[100005][2];

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < m; i++){
		int x,y;
		scanf("%d%d", &x, &y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	vis[1][0] = 1;
	queue <pair<int, int> > que;
	que.push({1, 0});	
	
	while(que.size()){
		pair<int, int> now = que.front();
		que.pop();
		
		for(int k = 0; k < edge[now.first].size(); k++){
			int to = edge[now.first][k];
			if(!vis[to][now.second ^ 1]){
				vis[to][now.second ^ 1] = 1;
				que.push({to, now.second ^ 1});
			}
		}
	}
	
	int res = 0;
	int res1 = 0;
	
	for(i = 1; i <= n; i++){
		if(!vis[i][0] && vis[i][1]){
			res++;
		}
		if(!vis[i][1] && vis[i][0]){
			res1++;
		}
	}
	
	long long tot = 1LL * res * (res - 1) / 2 + 1LL * res1 * (res1 - 1) / 2;
	printf("%lld\n", 1LL * n * (n - 1) / 2 - m - tot);
}


Measured memory_bytes: 6400
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    pair<int, char> card[9];
    for (int i = 0; i < 9; ++i) { scanf("%d", &card[i].first); }
    for (int i = 0; i < 9; ++i) { scanf(" %c", &card[i].second); }
    int ans = 0;
    sort(card, card+9);
    do {
      for (int i = 0; i < 3; ++i) {
        for (int j = 1; j < 3; ++j) {
          if (card[3*i+j].second != card[3*i].second) { goto bad; }
        }
        bool same = true;
        for (int j = 1; j < 3; ++j) {
          if (card[3*i+j].first != card[3*i].first) {
            same = false;
            break;
          }
        }
        bool renban = true;
        for (int j = 1; j < 3; ++j) {
          if (card[3*i+j].first != card[3*i+j-1].first + 1) {
            renban = false;
            break;
          }
        }
        if (!same && !renban) { goto bad; }
      }
      ans = 1;
      break;
bad:;
    } while (next_permutation(card, card+9));
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
string s;
bool flag=true;
int Main(void){
    cin>>s;
    For(i,1,4){
        if(s.at(i)==s.at(i-1)) flag=false;
    }
    if(flag) cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
//#include<algorithm>  -> sorting
using namespace std;

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e3 + 3;

int M[N][N][2],A[N],n,i;

int f(int i, int p, int h){
    if(i == n) return abs(A[n] - A[p]);
    int &r = M[i][p][h];
    if(r != -1) return r;
    if(h == 0) r = min(f(i+1,p,0) , f(i+1,i,1));
    if(h == 1) r = max(f(i+1,p,1) , f(i+1,i,0));
    return r;
}

signed main(){
    cin >> n >> i >> A[0];
    for(i=1;i<=n;i++) cin >> A[i];
    memset(M , -1 , sizeof M);
    cout << f(1,0,1);
    return 0;
}

Measured memory_bytes: 31744
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N,M;
vi H, A, B, d[MAXN];

void solve(){
    rep(i, N){
        ans++;
        rep(j, d[i].size()){
            int id = d[i][j];

            if(H[i] <= H[id]){
                // cout << i << endl;
                ans--;
                break;
            }
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> N >> M;
    H.resize(N);
    A.resize(M);
    B.resize(M);

    rep(i, N) cin >> H[i];

    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;

        d[A[i]].push_back(B[i]);
        d[B[i]].push_back(A[i]);
    }

    solve();
}


Measured memory_bytes: 9532
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>                                               //pow,powf
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define rep(i,n) for(int i=0; i<n; i++)
#define MAX 100005

int n,a[MAX];

int main(){
  
  cin>>n;
  rep(i, n) {
    cin>>a[i];
  }
  
  sort(a, a+n);
  if(n==2) {
    cout<<a[1]<<' '<<a[0]<<en
    return 0;
  }
  if(n==3){
    cout<<a[2]<<' '<<a[1]<<en
  }
  
  int maxa=a[n-1];
  int t=maxa/2;
  int lb=0,ub=n;
  rep(j, 100){
    int mid=(lb+ub)/2;
    if(a[mid]==t) {
      cout<<maxa<<' '<<a[mid]<<en
      return 0;
    }
    if(a[mid]>t){
      ub=mid;
    }else lb=mid;
  }
  if(a[ub]>t){
    if(abs(t-a[ub-1])<abs(t-a[ub])){
      ub=ub-1;
    }
  }else{
    if(abs(t-a[ub+1])<abs(t-a[ub])){
      ub=ub+1;
    }
  }
  
  cout<<maxa<<' '<<a[ub]<<en
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,last=1;
	cin>>n;
	for(int i=1;i<=10000000;i++){
	if(i*i>n){
		cout<<last<<endl;
		return 0;
	}
	last=i*i;
}
	return 0;
	
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    ll n,k;
    cin >> n >> k;
    int ar[n];
    fore(i,0,n) cin >> ar[i];
    int weight[n];
    weight[0] = 0;
    weight[1] = abs(ar[1]-ar[0]);
    fore(i,2,n) {
        ll mini = abs(ar[i] - ar[i-1])+weight[i-1];
        ll m = min(k,i);
        fore(j,2,m+1){
            int curr = abs(ar[i] - ar[i-j])+weight[i-j];
            if(curr < mini) mini = curr;
        }
        weight[i] = mini;
    }
    cout << weight[n-1] << "\n";
    return 0;
}


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

int main() {
  int N , i;
  int ret = 0;
  int ren = 0;
  cin >> N;
vector<int> vec(N);
  for (i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
    reverse(vec.begin(), vec.end());
  for(int j = 0; j < vec.size();j++){
    if( j % 2 == 0)
      ret += vec.at(j);
      else{
        ren += vec.at(j);
    }
    }
  cout << ret - ren;
  }

Measured memory_bytes: 256
// C++ 14
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>

#define ll long long
#define Int int
#define INTMAX (1 << 21)
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(Int x = start; x > end; x--)

using namespace std;

#define MAX 100


void dfs(vector<Int> vs[], Int n) {
    Int t = 0;
    bool visited[n];
    Int ds[n];
    Int fs[n];
    
    loop(i,0,n) {
        visited[i] = false;
        ds[i] = fs[i] = 0;
    }
    
    stack<Int> S;
    loop(i,0,n) {
        if (visited[i]) continue;
        
        S.push(i);
        visited[i] = true;
        ds[i] = ++t;
    
loop:
        while (!S.empty()) {
            Int i = S.top();
            for (auto c: vs[i]) {
                if (visited[c]) continue;
                S.push(c);
                visited[c] = true;
                ds[c] = ++t;
                goto loop;
            }
            
            S.pop();
            fs[i] = ++t;
        }
    }
    
    loop(i,0,n) cout << i+1 << " " << ds[i] << " " << fs[i] << endl;
}


int main(void){
    Int n, x, cc, c;
    cin >> n;
    vector<Int> vs[n];
    loop(i,0,n) {
        cin >> x >> cc;
        loop(j,0,cc) {
            cin >> c;
            vs[x-1].push_back(c-1);
        }
        
    }
    dfs(vs, n);
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  ll n;
  cin >> n;
  vector<long long> c(n);
  rep(i,n){
    char s;
    cin >> s;
    if(s == 'R'){
      c[i] = 1;
    }
    else{
      c[i] = 0;
    }
  }
  ll r = 0;
  ll w = 0;
  rep(i,n){
    if(c[i] == 1){
      r++;
    }
  }
  rep(i,n){
    if(c[i] == 0){
      w++;
    }
  }
  
  ll R = r;
  ll W = 0;
  ll ans = max(R,W);
  
  rep(i,n){
    if(c[i] == 1){
      R = R-1;
    }
    if(c[i] == 0){
      W = W+1;
    }
    ans = min(ans,max(R,W));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 4776
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long a = scanner.nextInt();
        long b = scanner.nextInt();
        long cost = 0;
        long[] x = new long[n];
        x[0] = scanner.nextInt();
        for (int i = 1; i < n; i++) {
            x[i] = scanner.nextInt();
            cost += Math.min(a * (x[i] - x[i - 1]), b);
        }
        System.out.println(cost);
    }
}

Measured memory_bytes: 48804
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;


int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1] ==b[0] && b[b.size()-1] ==c[0]) {
		cout<<"YES"<<endl;
	}
	else cout<<"NO";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

struct edge {int to, cost;};
typedef pair<int, int> P; // firstは最短距離, secondは頂点の番号

const int INF=1e9;
const int MAX_V=101010;
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];
int pre[MAX_V];

void dijkstra(int s){
  priority_queue<P, std::vector<P>, greater<P> > que;
  fill(d, d+V, INF);
  fill(pre,pre+V,-1);
  d[s]=0;
  que.push(P(0, s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second; // 頂点の番号
    if (d[v] < p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        pre[e.to]=v;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

vector<int> get_path(int t){
  // s to t;
  vector<int> path;
  for(;t!=-1;t=pre[t]) path.push_back(t);
  reverse(path.begin(),path.end());
  return path;
}

int main(){
  cin>>V>>E;
  rep(i,E){
    int A,B; cin>>A>>B; A--,B--;
    G[A].push_back({B,1});
    G[B].push_back({A,1});
  }
  dijkstra(0);
  cout<<"Yes\n";
  for(int i=1;i<V;i++) cout<<pre[i]+1<<endl;
  return 0;
}

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

ll fastsolve(int n, int m, vector<int> a) {
    vector<vector<ll> > b(3, vector<ll>(m));

    for (int i = 0; i < n - 1; i++) {
        int x = a[i];
        int y = a[i + 1];

        int len;
        if (x < y) len = y - x;
        else len = (m - x) + y;

        b[1][0] += len;
        if (len <= 1) continue;

        if (x < y) {
            b[2][x + 2]--;
        } else {
            if (x + 1 == m) {
                b[2][1]--;
            } else {
                if (x + 2 < m) b[2][x + 2]--;
                b[2][0]--;
                b[1][0] -= m - (x + 2);
            }
        }
        if (y < m - 1) {
            b[2][y + 1]++;
            b[1][y + 1] += len - 1;
        }
    }
    for (int i = 2; i >= 1; i--) {
        for (int j = 0; j < m; j++) {
            if (j) b[i][j] += b[i][j - 1];
            if (i) b[i - 1][j] += b[i][j];
        }
    }
    ll mn = 1e18;
    for (int i = 0; i < m; i++) mn = min(mn, b[0][i]);
    return mn;
}

ll slowsolve(int n, int m, vector<int> a) {
    ll res = 1e18;
    for (int c = 0; c < m; c++) {
        ll cur = 0;
        for (int i = 0; i < n - 1; i++) {
            int x = a[i];
            int y = a[i + 1];
            if (x < y) {
                if (x < c && c <= y) cur += 1 + y - c;
                else cur += y - x;
            } else {
                if (x < c) cur += 1 + m - c + y;
                else if (c <= y) cur += 1 + y - c;
                else cur += m - x + y;
            }
        }
        res = min(res, cur);
    }
    return res;
}

void stress() {
    for (int it = 316;; it++) {
        cerr << it << endl;
        srand(it);

        int n = rand() % 10 + 1;
        int m = rand() % 10 + 2;
        vector<int> a(n);
        a[0] = rand() % m;
        for (int i = 1; i < n; i++) {
            a[i] = a[i - 1];
            while (a[i] == a[i - 1]) a[i] = rand() % m;
        }
        ll ans1 = fastsolve(n, m, a);
        ll ans2 = slowsolve(n, m, a);
        if (ans1 != ans2) {
            cerr << ans1 << " instead of " << ans2 << endl;
            cerr << n << " " << m << endl;
            for (int x : a) cerr << x << " ";
            cerr << endl;
            slowsolve(n, m, a);
            fastsolve(n, m, a);
            exit(0);
        }
    }
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    //stress();

    int n, m;
    bool first = 1;
    while (scanf("%d%d", &n, &m) == 2) {
        if (first) first = 0;
        else printf("\n");

        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            a[i]--;
        }

        cout << fastsolve(n, m, a) << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 4096
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int SX;
int SY;
int TX;
int TY;
char res[100000];
int ress;
int main(){
  int a, b, i;
  rd(SX);
  rd(SY);
  rd(TX);
  rd(TY);
  a = TX - SX;
  b = TY - SY;
  for(i=0;i<(a);i++){
    res[ress++] = 'R';
  }
  for(i=0;i<(b);i++){
    res[ress++] = 'U';
  }
  for(i=0;i<(a);i++){
    res[ress++] = 'L';
  }
  for(i=0;i<(b+1);i++){
    res[ress++] = 'D';
  }
  for(i=0;i<(a+1);i++){
    res[ress++] = 'R';
  }
  for(i=0;i<(b+1);i++){
    res[ress++] = 'U';
  }
  res[ress++] = 'L';
  res[ress++] = 'U';
  for(i=0;i<(a+1);i++){
    res[ress++] = 'L';
  }
  for(i=0;i<(b+1);i++){
    res[ress++] = 'D';
  }
  res[ress++] = 'R';
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190829-1

// --- original code ---
// int SX, SY, TX, TY;
// char res[1d5]; int ress;
// {
//   int a, b;
//   rd(SX,SY,TX,TY);
//   a = TX - SX;
//   b = TY - SY;
// 
//   rep(i,a) res[ress++] = 'R';
//   rep(i,b) res[ress++] = 'U';
//   rep(i,a) res[ress++] = 'L';
//   rep(i,b+1) res[ress++] = 'D';
//   rep(i,a+1) res[ress++] = 'R';
//   rep(i,b+1) res[ress++] = 'U';
//   res[ress++] = 'L';
//   res[ress++] = 'U';
//   rep(i,a+1) res[ress++] = 'L';
//   rep(i,b+1) res[ress++] = 'D';
//   res[ress++] = 'R';
//   wt(res);
// }


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

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

A.sort()

minimum, maximum = A[0], A[-1]
xy = []

for i in range(1,N-1):
    num = A[i]
    if num >= 0:
        xy.append((minimum, num))
        minimum -= num
    else:
        xy.append((maximum, num))
        maximum -= num

xy.append((maximum, minimum))
print(maximum-minimum)
for x, y in xy:
    print(x,y)



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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    int H, W, M;
    cin >> H >> W >> M;
    vi hb(H+1,0), wb(W+1,0);
    set<intpair> bombs;
    rep(i,M){
        int h, w;
        cin >> h >> w;
        hb[h]++; wb[w]++;
        bombs.insert({h,w});
    }
    
    int maxH = 0, maxW = 0;
    set<int> selectedH, selectedW;
    
    rep(i,H+1){
        if(maxH < hb[i]) selectedH.clear();
        if(maxH <= hb[i]){
            selectedH.insert(i);
            maxH = hb[i];
        }
    }
    rep(i,W+1){
        if(maxW < wb[i]) selectedW.clear();
        if(maxW <= wb[i]){
            selectedW.insert(i);
            maxW = wb[i];
        }
    }
    
    int place = selectedW.size() * selectedH.size();
    for(auto [h, w] : bombs){
        if(selectedH.count(h) && selectedW.count(w)){
            place--;
        }
    }
    
    cout << maxH + maxW - (!place) << endl;
}

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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int area = W*H;
    int top = H, bottom = 0, left = 0, right = W;
    rep(i, N) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) left = max(x, left);
        if (a == 2) right = min(x, right);
        if (a == 3) bottom = max(y, bottom);
        if (a == 4) top = min(y, top);
    }
    int white_area = max(0, top - bottom)*max(0, right - left);
    cout << white_area << endl;
    return 0;
}

Measured memory_bytes: 256
def combination(arr, i, n)
  result = []
  
  if n == i
    return arr.sum
  end
  result << combination(arr.dup, i+1, n)
  arr [i] = 0
  result << combination(arr.dup, i+1, n)

  return result.flatten
end

n = gets.chomp.to_i
a = gets.split(" ").map { |x| x.chomp.to_i }
q = gets.chomp.to_i
m = gets.split(" ").map { |x| x.chomp.to_i }

result = combination(a, 0, n).uniq

m.each do |x|
  if result.include?(x)
    puts 'yes'
  else
    puts 'no'
  end
end





Measured memory_bytes: 44772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main() {
	ll n, m, ans = 700, A[10101];
	string S;
	cin >> S;
	rep(i, 3)
		if (S[i] == 'o')
			ans += 100;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import fileinput;

data = []

for line in fileinput.input():
    data.append(line)

N = int(data[0].split(' ')[0])
X = int(data[0].split(' ')[1])

ingr = list(map(int, data[1:]))

for item in ingr:
    X -= item

maxnum = len(ingr)
target = min(ingr)
while True:
    possible = X // target
    maxnum += possible
    if possible == 0:
        break
    X -= possible * target
    ingr.remove(target)
    target = min(ingr)

print(maxnum)

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

void solve(std::string a, std::string b){
    int i, j;
    if (a == "H") i = 1;
    else i = -1;
    if (b == "H") j = 1;
    else j = -1;
    if (i * j == 1) cout << 'H' << '\n';
    else cout << 'D' << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string a;
    std::cin >> a;
    std::string b;
    std::cin >> b;
    solve(a, b);
    return 0;
}


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

int main(int argc, const char * argv[]) {
    
    int n;
    int d[110];
    int a;
    int answer=0;
    int counter=1;
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    
    for(int i=0;i<n-1;i++){
        for(int j=0;j<n-1;j++){
            if(d[j]<d[j+1]){
                a=d[j];
                d[j]=d[j+1];
                d[j+1]=a;
            }
        }
    }
    
    for(int i=0;i<n-1;i++){
        if(d[i]>d[i+1]){
            counter++;
        }
        
        
        if(counter>answer) answer=counter;
    }
    
    if(n==1) answer=1;
    
    cout << answer << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intt long long
using namespace std;
int i , j ;
int main ()
{
    intt t;
    string s;
    cin >> s >> t;
    intt k , l;
    bool flag = false;
    for ( i = 0 ; i < s.size() ; i++ )
    {
        if ( s[i] != '1' )
        {
            k = i+1;
            l = s[i] - '0';
            flag = true;
            break;
        }
    }
    if ( !flag )
    {
        cout << 1 << endl;
        return 0;
    }
    if ( t < k )
    {
        cout << 1 << endl;
        return 0;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        string answer = "";

        if (a == b)
        {
            answer = "Draw";
        }
        else if (a == 1)
        {
            answer = "Alice";
        }
        else if (b == 1)
        {
            answer = "Bob";
        }
        else
        {
            answer = a > b ? "Alice" : "Bob";
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string n; cin >> n;
    if((n[0]==n[1] && n[1] == n[2]) || (n[1]==n[2] && n[2]==n[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  double a,b; cin >> a >> b;
  cout << ceil((a+b)/2) << endl;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = 998244353;

int add(int a, int b)
{
   int res = a + b;
   if(res >= MOD)
      return res - MOD;
   return res;
}

int mult(int a, int b)
{
   long long res = a;
   res *= b;
   if(res >= MOD)
      return res % MOD;
   return res;
}

const int N = 2e5 + 5;

int PW[N];
int ele[N];

class segmentTree {
public:
   int n;
   vector<int> t;
   vector<bool> left;
   vector<int> lazy;
 
   segmentTree() { }
   
   segmentTree(int n) {
      this->n = n;
      t.resize(4 * n + 5, 0);
      left.resize(4 * n + 5, 0);
      lazy.resize(4 * n + 5, 0);
   }
    
   void push(int v, int tl, int tr) {
      if (left[v] == false) return ;
 
      t[v] = mult(lazy[v], ele[tr - tl + 1]);
      
      if (tl != tr) {
         int tm = (tl + tr) / 2;
         lazy[2 * v] = lazy[v];
         left[2 * v] = true;
         lazy[2 * v + 1] = lazy[v];
         left[2 * v + 1] = true;
      }
 
      lazy[v] = 0;
      left[v] = false;
   }
 
   void update(int v, int tl, int tr, int l, int r, int val) {
      push(v, tl, tr);
 
      if (tl > tr || tl > r || tr < l) return ;
      if (tl >= l && tr <= r) {
         left[v] = true;
         lazy[v] = val;
         push(v, tl, tr);
         return ;
      }
      
      int tm = (tl + tr) / 2;
      update(2 * v, tl, tm, l, r, val);
      update(2 * v + 1, tm + 1, tr, l, r, val);

      t[v] = add(mult(t[2*v], PW[tr - tm] ), t[2*v + 1]);
   }
 
   int query(int v, int tl, int tr, int l, int r) {
      push(v, tl, tr);
      if (tl > tr || tl > r || tr < l) return 0;
 
      if(tl >= l && tr <= r){
         return t[v];
      }

      int tm = (tl + tr) / 2;
      return add(mult(query(2*v, tl, tm, l, r), PW[tr - tm]), query(2*v + 1, tm + 1, tr, l, r));
   }
};

int32_t main() {
   fast;
   PW[0] = 1;
   ele[1] = 1;

   f(i,1,N) PW[i] = mult(PW[i-1], 10);

   f(i,2,N) ele[i] = add(ele[i-1], PW[i-1]);

   int n,q;
   cin >> n >> q;

   segmentTree st(n+1);
   st.update(1,1,n,1,n,1);

   while(q--){
      int l,r,x;
      cin >> l >> r >> x;
      st.update(1,1,n,l,r,x);
      cout << st.query(1,1,n,1,n) << "\n";
   }
}

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

def main():
    H, W, D = map(int, input().split())
    A = list(list(map(int, input().split())) for _ in range(H))
    Q = int(input())
    B = [(0,0)] * (H * W + 5)
    for h in range(H):
        for w in range(W): 
            B[A[h][w]] = (h+1, w+1)


    C = [0] * (H * W + 5)
    for i in range(H * W + 1):
        if i // D == 0:
            continue
        tmp = abs(B[i][0] - B[i-D][0]) + abs(B[i][1] - B[i-D][1]) 
        C[i] = tmp + C[i - D]

    for _ in range(Q):
        L, R = map(int, input().split())
        print(C[R] - C[L])


if __name__ == "__main__":
    main()

Measured memory_bytes: 56536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
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);
        DHandstand2 solver = new DHandstand2();
        solver.solve(1, in, out);
        out.close();
    }

    static class DHandstand2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int[][] count = new int[10][10];
            for (int i = 1; i <= n; i++) {
                int a = Integer.toString(i).charAt(0) - '0';
                int b = i % 10;

                count[a][b]++;
            }

            long answer = 0;
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    long x = count[i][j], y = count[j][i];
                    answer += x * y;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 32212
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w = li()
s = []
s.append(["#"]*(w+2))
for _ in range(h):
    temp = ["#"]
    temp = temp + lc()
    temp = temp + ["#"]
    s.append(temp)
              
s.append(["#"]*(w+2))
          
for si in s:
    print("".join(si))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int MOD = 1e9+7;

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

    int n;
    cin >> n;
    vector<int> count(27,1);
    for(int i = 0; i < n; i++){
        char a;
        cin >> a;
        count[a - 'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 27; i++){
        ans *= count[i];
        ans %= MOD;
    }
    ans = (ans + MOD - 1) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;


int main(){
    FASTIO
    int n;
    cin >> n;
    n %= 1000;
    if(n != 0)
    	n = 1000 - n;
    cout << n;
    return 0;
}

Measured memory_bytes: 3648
I = []
N = int(input())
for i in range(N):
    s, p = map(str,input().split())
    I.append([s, i+1, 100-int(p)])
    

sorted_I = sorted(I, key=lambda x:(x[0],x[2]))

for i in range(N):
    print(sorted_I[i][1])



Measured memory_bytes: 3060
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;

//--------------------------------------------------

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

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

//---------------------------------------------------

void Main()
{
	int a, b,f=1; cin >> a >> b;
	float amin = a / 0.08f,
		amax = (a + 1) / 0.08f,
		bmin = b / 0.1f,
		bmax = (b + 1) / 0.1f;
	amin = ceil(amin);
	amax = floor(amax);
	bmax--;
	for (int i = max(amin, bmin); i < min(amax, bmax); i++) {
		cout << i << endl;
		f = 0;
		break;
	}
	if (f)cout << -1 << endl;
	
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	
	return 0;
}

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

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

    if(N%2==1){
        if(K<=(N+1)/2) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else{
        if(K<=N/2) cout << "YES" << endl;
        else cout <<  "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>

#define X first
#define Y second
#define PB push_back

using namespace std;

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

const int N = 5050;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

int n, a, b, dp[N][N][2][2], pref[N][N][2][2], pos_pref[N][2][2];

inline int add(int A,int B){
	if(A + B >= MOD) 
		return A + B - MOD;
	return A + B;
}

inline int sub(int A, int B){
	if(A - B < 0)
		return A - B + MOD;
	return A - B;
}

void dinamika(){
	for(int k = 0;k <= n;k++){
		for(int fl = 0;fl < 2;fl++){
			for(int lst = 0;lst < 2;lst++){
				dp[n][k][fl][lst] = (n - k) >= b || fl;
				pref[n][k][fl][lst] = dp[n][k][fl][lst];
				if(n == k){
					pos_pref[n][fl][lst] = dp[n][n][fl][lst];
				}
			}
		}
	}
	for(int i = n - 1;i >= 0;i--){
		for(int k = i;k >= 0;k--){
			for(int lst = 0;lst < 2;lst++){
				for(int fl = 0;fl < 2;fl++){
					int ret = 0, tfl = fl || (i - k) >= b;
					if(!lst){
						ret = pref[i + 1][k][tfl][1];
					}
					else{
						if(a + i <= n){
							ret = pref[a + i][k][tfl][0];
							ret = add(ret, sub(pos_pref[i + 1][tfl][0], pos_pref[a + i][tfl][0]));					
						}
						else{
							ret = pos_pref[i + 1][tfl][0];
						}
					}
					dp[i][k][fl][lst] = ret;
					pref[i][k][fl][lst] = add(pref[i + 1][k][fl][lst], dp[i][k][fl][lst]);
					if(i == k){
						pos_pref[i][fl][lst] = add(dp[i][i][fl][lst], pos_pref[i + 1][fl][lst]);
					}
				}
			}
		}
	}
}

int main(){
	scanf("%d%d%d", &n, &a, &b);
	if(a > b) swap(a, b);
	dinamika();
	printf("%d\n", add(dp[0][0][0][0], dp[0][0][0][1]));
	return 0;
}

Measured memory_bytes: 433884
// Easy Linear Programming
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    long long A, B, C, K, ma = 0;
    cin >> A >> B >> C >> K;
    if (K >= A) {
        ma += A;
    } else {
        ma += K;
        cout << ma << endl;
        return 0;
    }
    if (K - A - B <= 0) {
        ma += 0;
    } else if (K - A - B < C) {
        ma -= K - A - B;
    } else  {
        ma -= C;
    }
    cout << ma << endl;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val mod = 998244353L

    val N = readInputLine().toInt()

    val DList = readInputLine().split(" ").map { it.toInt() }
    
    if (DList[0] != 0 || DList.count { it == 0 } != 1) {
        println(0)
        return
    }
    
    val distCnt = IntArray(N)
    val maxDist = DList.max()!!

    DList.forEach { distCnt[it]++ }
    
    var ans = 1L
    
    for (i in 1..maxDist) {
        for (j in 1..distCnt[i]) {
            ans *= distCnt[i - 1].toLong()
            ans %= mod
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 51052
import sys
l=[[int(i) for i in l.split()] for l in sys.stdin]
for i in l:
    a,b,c,d,e,f=i
    x=round((c*e-b*f)/(a*e-b*d),3)
    y=round((c*d-a*f)/(b*d-a*e),3)
    if x==0:
        x=0
    if y==0:
        y=0
    print("{:.3f} {:.3f}".format(x,y))



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

const int MAX_N = 1e5+10;
int N;
string S;
map<char, int> seen;
const int MOD = 1e9+7;

void solve()
{
	for(auto c : S) seen[c]++;
	ll ans = 1;
	for(auto it=seen.begin(); it!= seen.end(); ++it){
		ans = (ans * (it->second+1)) % MOD;
	}
	if(!ans) cout << 0 << endl;
	else cout << ans - 1 << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> S;
	solve();
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23252
n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
c=1
x=y=0
for i in range(n-1):
    if A[i]==A[i+1]:
        c+=1
        if c==2:
            if x!=0:
                y=A[i]
                break
            else:
                x=A[i]
        if c==4:
            x=y=A[i]
            break
    else:
        c=1
print(x*y)



Measured memory_bytes: 19936