akhauriyash/Code-Regression huggingface dataset:
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> B(N, 1);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    int a, b;
    while (cin >> a >> b) {
        a--, b--;
        if (H.at(a) < H.at(b)) {
            B.at(a) = 0;
        }
        else if (H.at(a) > H.at(b)) {
            B.at(b) = 0;
        }
        else {
            B.at(a) = B.at(b) = 0;
        }
    }
    int cnt = 0;
    for (auto b : B) {
        cnt += b;
    }
    cout << cnt << "\n";
}

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

cnt = 0
result = {}
x = 1
if(N == 1):
  print(1)
  exit()
else:
  for i in range(1,N+1):
    while i%2 == 0:
      i //= 2
      cnt += 1
      x += 1
      result[x] = cnt
    cnt = 0
print(max(result, key = result.get))

Measured memory_bytes: 3316
g=lambda a,b,c:(a[0]-b[0])*(b[1]-c[1])-(b[0]-c[0])*(a[1]-b[1])

while True:
    try:t=input()
    except:break
    l=[float(i) for i in t.split()]
    b=[g(l[0:2],l[2:4],l[6:8]),g(l[2:4],l[4:6],l[6:8]),g(l[4:6],l[0:2],l[6:8])]
    if len([i for i in b if i>0])==3 or len([i for i in b if i<0])==3:
        print("YES")
    else:
        print("NO")


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

int main() {
    int N,K;
    cin >> N >> K;
    int H[N];
    for(int i = 0; i < N; ++i) cin >> H[i];
    
    sort(H,H+N,greater<>());
    long sum = 0;

    for(int i = K; i < N; ++i){
        sum += H[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <vector>
#include <string>

using namespace std;

bool check(const string& s, const string& t) {
    set<char> ss, ts;
    for(char c: s) {
        ss.insert(c);
    }
    for(char c: t) {
        ts.insert(c);
    }
    for(char c: ts) {
        if(ss.find(c) == ss.end()) {
            return false;
        }
    }
    return true;
}

int main() {
    string s, t;
    cin >> s >> t;
    int slen = s.length();
    vector<vector<int>> table(s.size()+1, vector<int>(27, -1));

    if(!check(s, t)) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = slen - 2; 0 <= i; i--) {
        table[i] = table[i + 1];
        table[i][s[i + 1] - 'a'] = i + 1;
    }

    long long ans = 0;
    int lastindex = -1;
    for(int i = 0; i < t.length(); i++) {
        if(lastindex == -1) {
            if(s[0] == t[i]){
                lastindex = 0;
            }else{
                lastindex = table[0][t[i]-'a'];
            }
        } else {
            lastindex = table[lastindex][t[i]-'a'];;
        }
        if(lastindex == -1) {
            ans += slen;
            i--;
        }
    }

    ans += lastindex + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15360
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var words = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine()).ToArray();
        Console.WriteLine(words.Zip(words.Skip(1), (x, y) => x.Last() == y.First()).All(x => x) && words.Distinct().Count() == n ? "Yes" : "No");
    }
}

Measured memory_bytes: 13524
class Node
  attr_accessor :key, :left, :right, :parent
  def initialize key
    @key = key
  end
  def inorder
    left.inorder if left
    print ' ', key
    right.inorder if right
  end
  def preorder
    print ' ', key
    left.preorder if left
    right.preorder if right
  end
  def in
    left.in if left
    $a << self
  end
end

def insert
  z = Node.new $key
  x = $root
  while x
    y = x
    x = z.key < x.key ? x.left : x.right
  end
  z.parent=y
  unless y
    $root = z
  else
    z.key < y.key ? y.left = z : y.right = z
  end
end

def find root
  if root == nil
    puts 'no'
  elsif $key == root.key
    puts 'yes'
  elsif $key < root.key
    find root.left
  else
    find root.right
  end
end

def delete1 parent, node
  if parent
    if l = parent.left
      $key == l.key ? parent.left = node : parent.right = node
    else
      parent.right = node
    end
  else
    $root = node
  end
  node.parent = parent
end
def delete root
  left = root.left
  right = root.right
  if $key == root.key
    parent = root.parent
    if (left || right) == nil
      if l = parent.left
        $key == l.key ? parent.left = nil : parent.right = nil
      else
        parent.right = nil
      end
    elsif left && right
      $a=[]
      right.in
      root.key = $key = $a[0].key
      delete $a[0]
    elsif left
      delete1 parent, left
    else
      delete1 parent, right
    end
  elsif $key < root.key
    delete left
  else
    delete right
  end
end
gets.to_i.times {
    command, $key = gets.split
    $key=$key.to_i
    case command
    when 'insert'
      insert
    when 'find'
      find $root
    when 'delete'
      delete $root
    else
      $root.inorder
      puts
      $root.preorder
      puts
    end
}

Measured memory_bytes: 158448
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[][] xl=new int[n][2];
		for(int i=0; i<n; i++){
			int x=sc.nextInt();
			int l=sc.nextInt();
			xl[i][0]=x-l;
			xl[i][1]=x+l;
		}
		Arrays.sort(xl,(x,y) -> x[1]-y[1]);
		int ans=1;
		int point=xl[0][1];
		for(int i=1; i<n; i++){
			if(point<=xl[i][0]){
				ans++;
				point=xl[i][1];
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
  int q;
  cin >> q;
  list<int> lst;
  auto itr = lst.end();
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a;
    if (a == 0) {
      cin >> b;
      lst.insert(itr, b);
      itr--;
    }
    if (a == 1) {
      cin >> b;
      if (b >= 0) {
        for (int j = 0; j < b; j++) {
          itr++;
        }
      } else {
        for (int j = 0; j < abs(b); j++) {
          itr--;
        }
      }
    }
    if (a == 2) {
      itr = lst.erase(itr);
    }
  }
  for (auto itr = lst.begin(); itr != lst.end(); itr++) {
    cout << *itr << endl;
  }
}



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

int main(){
  int p,q,t,ans=1,num;
  set<int> s;
  cin>>p>>q;
  num=t=q/__gcd(p,q);
  for(int i=2;i*i<=num;i++){
    if(!(num%i)){
      s.insert(i);
      while(!(num%i))num/=i;
    }
  }
  if(num!=1)s.insert(num);
  set<int>::iterator ite=s.begin();
  while(ite!=s.end())ans*=*ite,ite++;
  if(ans==1)ans=t;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3108
let id x = x

let (r,g,b) = Scanf.scanf "%d %d %d\n" (fun a b c -> (a,b,c))

let x = r * 100 + g * 10 + b  

let ans = if x mod 4 = 0 then "YES" else "NO"

let () =
  Printf.printf "%s\n" ans

Measured memory_bytes: 384
import heapq
n = int(input())
tasks = []
for _ in range(n):
    a, b = map(int, input().split())
    tasks.append([b, a])

heapq.heapify(tasks)

ans = "Yes"
time = 0
while len(tasks) > 0 :
    task = heapq.heappop(tasks)
    time += task[1]

    if task[0] < time:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 34832
w = input()
cnt = 0
while True:
    s = input()
    if s == 'END_OF_TEXT':
        break
    se = ''
    for c in s:
        if ord('A') <= ord(c) <=ord('Z'):
            se += chr(ord(c) + 32)
        else: se += c
    sent = se.split() 
    for wd in sent:
        if wd == w: cnt += 1
print(cnt)



Measured memory_bytes: 5556
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_],X;i,j,k,t;
//c(a,b)int*a,*b;{t=*a-*b?:a[1]-b[1];}
c(a,b)long*a,*b;{return*a<*b?-1:*a>*b;}
p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}
f(a,b){return F[a+b]*I[a]%M*I[b]%M;}
main(s){
  for(*I=1;++X<_;~scanf("%d",A+i)&&i++%2&&gets(P))I[X]=p(s=F[X]=X*s%M,M-2);
  for(qsort(A,i/2,8,c);j<i;P[j++-1]=X)
    for(X=f(t=--A[++j],s=--A[k=j]);k;
        X=s<A[k-=2]?X:(X-f(s-A[k],t-A[k+1])*P[k]%M+M)%M);
printf("%d",X);}

Measured memory_bytes: 14336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
        int y = sc.nextInt() / 1000;
        int one = 0,five = 0,ten = n;
        int check;
        try{
        while(one * 1 + five * 5 + ten * 10 != y){
          if(one * 1 + five * 5 + ten * 10 > y){
            ten--;
            one++;
          }else if(one * 1 + five * 5 + ten * 10 < y){
            one--;
            five++;
          }
          if(one < 0 || five < 0 || ten < 0){
            throw new Exception();
          }
        }    
          System.out.println(ten + " " + five + " " + one);
        }catch(Exception e){
          System.out.println(-1 + " " + -1 + " " + -1);
        }
    }
}

Measured memory_bytes: 39336
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
   fast_io
   ll a,b;
   cin>>a>>b;
   ll sum = a*b;
   ll ans = sum/(__gcd(a,b));
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n; cin >> n;
    vector<ll> ar(n);
    repl(i,n) cin >> ar[i];
    ll ans = 0;
    repl(i,63){
        ll a = 0;
        ll b = 0;
        repl(j,n){
            if (ar[j]>>i&1LL) a++;
            else b++;
        }

        ll k = a * b % MOD;
        rep(j,i) k = k * 2 % MOD;
        ans += k;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main() {
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
	} else {
		ll x = 1;
		ll ans = 0;
		while (x <= n) {
			x *= 5;
			ans += n / x / 2;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3596
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;
struct HopcroftKarp {
  vector< vector< int > > graph;
  vector< int > dist, match;
  vector< bool > used, vv;

  HopcroftKarp(int n, int m) : graph(n), match(m, -1), used(n) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
  }

  void bfs() {
    dist.assign(graph.size(), -1);
    queue< int > que;
    for(int i = 0; i < graph.size(); i++) {
      if(!used[i]) {
        que.emplace(i);
        dist[i] = 0;
      }
    }

    while(!que.empty()) {
      int a = que.front();
      que.pop();
      for(auto &b : graph[a]) {
        int c = match[b];
        if(c >= 0 && dist[c] == -1) {
          dist[c] = dist[a] + 1;
          que.emplace(c);
        }
      }
    }
  }

  bool dfs(int a) {
    vv[a] = true;
    for(auto &b : graph[a]) {
      int c = match[b];
      if(c < 0 || (!vv[c] && dist[c] == dist[a] + 1 && dfs(c))) {
        match[b] = a;
        used[a] = true;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching() {
    int ret = 0;
    while(true) {
      bfs();
      vv.assign(graph.size(), false);
      int flow = 0;
      for(int i = 0; i < graph.size(); i++) {
        if(!used[i] && dfs(i)) ++flow;
      }
      if(flow == 0) return (ret);
      ret += flow;
    }
  }

  void output() {
    for(int i = 0; i < match.size(); i++) {
      if(~match[i]) {
        cout << match[i] << "-" << i << endl;
      }
    }
  }
};


main(){
    int q=in();
    rep(iii,q){
        ll a=in(),b=in();
        if(a==b)cout<<(a-1)*2<<endl;
        else{
            if(a>b)swap(a,b);
            ll ans=a-1;
            ll c;
            ll l=0,r=1e9+1;
            while(l<r-1){
                ll mid=(l+r)/2;
                if(mid*mid<a*b)l=mid;
                else r=mid;
            }
            c=l;
            ll d=c;
            if(c*(d+1ll)<a*b){
                cout<<ans+c+c-a<<endl;
            }
            else{
                cout<<ans+c+c-a-1<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c,d;
  int sum;
  sum = 0;
  scanf("%d\n%d\n%d\n%d\n",&a,&b,&c,&d);
  if(a < b){
    sum = sum + a;
  }else{
    sum = sum + b;
  }
  if(c < d){
    sum = sum + c;
  }else{
    sum = sum + d;
  }
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 128
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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            int a = 0, b = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (in.next().equals("snuke")) {
                        a = i;
                        b = j;
                    }
                }
            }
            out.printf("%s%d\n", (char) ('A' + b), a + 1);
        }

    }

    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: 8912
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: i64,
        x: i64,
    }
    let ans = ((x - (k - 1))..(x + (k - 1) + 1))
        .map(|i| i.to_string())
        .collect::<Vec<_>>()
        .join(" ");
    println!("{}", ans);
}


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

long long n,k,A[200050],fw[200050];

void update(long long p, long long v)
{
	for(; p<=n; p+=p&(-p)) 
		fw[p]+=v;
}

long long query(long long p)
{
	long long ans=0;
	for(; p; p-=p&(-p)) 
		ans+=fw[p];
	return ans;
}

int main()
{
	cin>>n>>k;
	vector<long long> v;
	for(long long i=1; i<=n; i++)
	{
		cin>>A[i];
		A[i]+=A[i-1];
		v.push_back(A[i]-k*i);
	}
	sort(v.begin(), v.end());
	long long ans=0;
	for(long long i=0; i<=n; i++)
	{
		long long val=lower_bound(v.begin(), v.end(), A[i]-k*i)-v.begin()+1;
		ans+=query(val);
		update(val,1);
	}
	cout<<ans;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	string S;
	cin >> S;
	if(S=="AAA"||S=="BBB") cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

struct edge {
    int f, t, c;
    edge(int f = 0, int t = 0, int c = 0): f(f), t(t), c(c) {}
};

const ll INF = 1e18;
const int MAX_V = 1000;
const int MAX_E = 2000;
int N, M, a, b, c;
int negative[MAX_V + 1];
ll d[MAX_V + 1];
edge es[MAX_E + 1];

void bellmanford(int s) {
    fill(d + 1, d + 1 + N, INF);
    d[s] = 0;
    for (int i = 0; i < N - 1; i++) {
        bool update = false;
        for (int j = 0; j < M; j++) {
            edge e = es[j];
            if (d[e.f] != INF && d[e.t] > d[e.f] + e.c) {
                d[e.t] = d[e.f] + e.c;
                update = true;
            }
        }
        if (!update) break;
    }
}

int main(void) {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        es[i].f = a;
        es[i].t = b;
        es[i].c = -c;
    }

    bellmanford(1);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            edge e = es[j];
            if (d[e.f] != INF && d[e.t] > d[e.f] + e.c) {
                d[e.t] = d[e.f] + e.c;
                negative[e.t] = 1;
            }
            if (negative[e.f])
                negative[e.t] = 1;
        }
    }
    
    if (negative[N]) cout << "inf\n";
    else cout << -d[N] << endl;

    return 0;
}

Measured memory_bytes: 256
A=[[int(n) for n in input().split()] for m in range(3)]
N=int(input())

for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if b==A[j][k]:
                A[j][k]=0
                
ans="No"

for i in range(3):
    if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
        ans="Yes"

for i in range(3):
    if  A[0][i]==0 and A[1][i]==0 and A[2][i]==0: 
        ans="Yes"

if (A[0][0]==0 and A[1][1]==0 and A[2][2]==0) or (A[0][2]==0 and A[1][1]==0 and A[2][0]==0):
    ans="Yes"


print(ans)



Measured memory_bytes: 9160
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    int l = 0,r = 1,xors = a[0];
    ll sum = a[0];
    ll ans = 0;
    while(l < n) {
        while(r < n && (xors^a[r]) == (sum+a[r])) {
            xors ^= a[r];
            sum += a[r++];
        }
        ans += r-l;
        sum -= a[l];
        xors ^= a[l++];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, neg=0, pos=0;
    multiset<int> negs, poss;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(arr[i]<0)
        {
            neg++;
            negs.insert(arr[i]);
        }
        else
        {
            pos++;
            poss.insert(arr[i]);
        }
    }
    if(n==2)
    {
        sort(arr, arr+n);
        cout<<arr[1]-arr[0]<<endl;
        cout<<arr[1]<<" "<<arr[0];
        return 0;
    }
    vector<pair<int, int>> v;
    if(neg>0 && pos>0)
    {
        while(pos>1)
        {
            int x=*negs.begin(), y=*poss.begin();
            v.pb({x, y});
            negs.erase(negs.begin());
            poss.erase(poss.begin());
            negs.insert(x-y);
            pos--;
        }
        while(neg>1)
        {
            int x=*poss.begin(), y=*negs.begin();
            negs.erase(negs.begin());
            poss.erase(poss.begin());
            v.pb({x, y});
            poss.insert(x-y);
            neg--;
        }
        int x=*poss.begin(), y=*negs.begin();;
        cout<<x-y<<endl;
        v.pb({x, y});
        for(auto x:v)
            cout<<x.first<<" "<<x.second<<endl;
    }
    else if(neg>0)
    {
        int x=*negs.rbegin(), y=*negs.begin();
        neg-=2;
        negs.erase(negs.begin());
        negs.erase(negs.find(x));
        poss.insert(x-y);
        pos++;
        v.pb({x, y});
        while(pos>1)
        {
            x=*negs.begin(), y=*poss.begin();
            v.pb({x, y});
            negs.erase(negs.begin());
            poss.erase(poss.begin());
            negs.insert(x-y);
            pos--;
        }
        while(neg>1)
        {
            x=*poss.begin(), y=*negs.begin();
            negs.erase(negs.begin());
            poss.erase(poss.begin());
            v.pb({x, y});
            poss.insert(x-y);
            neg--;
        }
        x=*poss.begin(), y=*negs.begin();;
        cout<<x-y<<endl;
        v.pb({x, y});
        for(auto x:v)
            cout<<x.first<<" "<<x.second<<endl;
    }
    else
    {
        int x=*poss.begin(), y=*poss.rbegin();
        poss.erase(poss.begin());
        poss.erase(poss.find(y));
        pos-=2;
        neg++;
        negs.insert(x-y);
        v.pb({x, y});
        while(pos>1)
        {
            x=*negs.begin(), y=*poss.begin();
            v.pb({x, y});
            negs.erase(negs.begin());
            poss.erase(poss.begin());
            negs.insert(x-y);
            pos--;
        }
        while(neg>1)
        {
            x=*poss.begin(), y=*negs.begin();
            negs.erase(negs.begin());
            poss.erase(poss.begin());
            v.pb({x, y});
            poss.insert(x-y);
            neg--;
        }
        x=*poss.begin(), y=*negs.begin();;
        cout<<x-y<<endl;
        v.pb({x, y});
        for(auto x:v)
            cout<<x.first<<" "<<x.second<<endl;
    }
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using vll = vector<ll>;
using vld = vector<ld>;
using vpl = vector<pll>;
using vvll = vector<vll>;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(ll i=0;i<((ll)n);i++)
#define REP1(i,n) for(ll i=1;i<((ll)n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll mpow(ll m, ll p){
  ll power = m;
  ll res = 1;
  while(p>0){
    if(p&1)
      res = res*power%MOD;
    power = (power*power)%MOD;
    p /= 2;
  }
  return res;
}


ll mod_inv(ll m){
  return mpow(m, MOD-2);
}


struct COM{
  vll fact, fact_inv;
  COM(ll n): fact(n+1,1), fact_inv(n+1,1){
    for(ll i=1; i<=n; i++)
      fact[i] = fact[i-1]*i%MOD;
    fact_inv[n] = mod_inv(fact[n]);
    for(ll i=n; i>=1; i--)
      fact_inv[i-1] = fact_inv[i]*i%MOD;
  }

  ll calc(ll n, ll k){
    if(k<0 || n<k)
      return 0;
    ll res = fact[n]*fact_inv[n-k]%MOD*fact_inv[k]%MOD;
    return res;
  }
};


//agc040
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = s.size();

    ll ans = 0;
    COM com(k+n);
    REP(i, k + 1) {
        ll now = com.calc(k - i + n - 1, n - 1) * mpow(25, k - i) % MOD * mpow(26, i) % MOD;
        ans = (ans + now) % MOD;
    }

    cout << ans << endl;
}




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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int counter = 0;
    int searchingNum = 1;

    for (int i = 0; i < n; i++)
    {
        if (searchingNum == a[i])
        {
            counter += 1;
            searchingNum += 1;
        }
    }

    if (counter == 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << n - counter << endl;
    }
}


Measured memory_bytes: 1024
n=int(input())

w=[]
for _ in range(n):
    w.append(input())

if len(list(set(w)))!=len(w):
    print("No")
    exit()

temp=w[0][0]

for item in w:
    if temp!=item[0]:
        print("No")
        exit()
    else:
        temp=item[-1]

print("Yes")

    


Measured memory_bytes: 38384
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Foldable
import Data.Char

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn :: IO Int
    mapM_ putStrLn $ solve n


solve n = solveAux 'a' n n

solveAux cur _     0  = [""]
solveAux cur ltrn len = do
    c <- take ltrn ['a'..cur]
    map (c:) (solveAux (max cur (nxt c) ) ltrn (len-1))


nxt c = chr (ord c + 1)


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

int v[3][N], dp[N][3], n;

int solve(int i, int choose){
    if(i == n)
        return 0;
    if(dp[i][choose] != -1)
        return dp[i][choose];
    int ans = 0;
    for(int j = 0; j < 3; j++){
        if(i != 0 and j == choose)
            continue;
        ans = max(ans, solve(i+1, j) + v[j][i]);
    }
    return dp[i][choose] = ans;
}

int main(){
	fastio;
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[0][i] >> v[1][i] >> v[2][i];
    cout << solve(0,0)  << '\n';
}


Measured memory_bytes: 13740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,k; cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    sort(h.begin(),h.end());
    ll ans=1001001001001;
    rep(i,n-k+1) chmin(ans,h[i+k-1]-h[i]);
    cout<<ans<<endl;
    return 0;
}

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

class UnionFind {
	vector<int>par, sz;
public:
	UnionFind() {}
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};
int cnt[2000][2];
bitset<701>dp;
bool f[700][700];

int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		if(a>b)swap(a,b);
		f[a][b]=true;
	}
	UnionFind uf(n*2);
	rep(i,n)for(int j=i+1;j<n;j++){
		if(!f[i][j]){
			uf.unite(i,j+n);
			uf.unite(i+n,j);
		}
	}
	rep(i,2*n){
		if(i<n&&uf.same(i,n+i)){
			puts("-1");return 0;
		}
		cnt[uf.find(i)][i>=n]++;
	}
	dp[0]=1;
	rep(i,n){
		if(uf.find(i)==i){
			dp=dp<<cnt[i][0]|dp<<cnt[i][1];
		}
	}
	int Min=INT_MAX;
	rep(i,n+1){
		if(dp[i]){
			Min=min(Min,i*(i-1)/2+(n-i)*(n-i-1)/2);
		}
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 768
// AOJ ITP2_10_C Bit Flag
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()   // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(unsigned long long n)   // 非負整数の表示、最後に改行あり
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

int bitcount64(unsigned long long x)
{
	x = ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1 ) + (x & 0x5555555555555555ULL);
	x = ((x & 0xCCCCCCCCCCCCCCCCULL) >> 2 ) + (x & 0x3333333333333333ULL);
	x = ((x & 0xF0F0F0F0F0F0F0F0ULL) >> 4 ) + (x & 0x0F0F0F0F0F0F0F0FULL);
	x = ((x & 0xFF00FF00FF00FF00ULL) >> 8 ) + (x & 0x00FF00FF00FF00FFULL);
	x = ((x & 0xFFFF0000FFFF0000ULL) >> 16) + (x & 0x0000FFFF0000FFFFULL);
	x = ((x & 0xFFFFFFFF00000000ULL) >> 32) + (x & 0x00000000FFFFFFFFULL);
	return (int)x;
}

int main()
{
	unsigned q, c, i;
	unsigned long long n;

	q = in(), n = 0;
	while (q--) {
		c = gc() & 0xf, gc();
		switch (c) {
		case 0: i = in(), pc((n & (1LL << i)) ? '1' : '0'), pc('\n'); break;
		case 1: i = in(), n |= 1LL << i; break;
		case 2: i = in(), n &= ~(1LL << i); break;
		case 3: i = in(), n ^= 1LL << i; break;
		case 4: pc(n == 0xffffffffffffffffULL ? '1' : '0'), pc('\n'); break;
		case 5: pc(n ? '1' : '0'), pc('\n'); break;
		case 6: pc(!n ? '1' : '0'), pc('\n'); break;
		case 7: out(bitcount64(n)); break;
		case 8: out(n); break;
		}
	}
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> data(H);
  for(int i = 0; i < H; i++) {
    cin >> data.at(i);
  }
  vector<vector<int>> L(H, vector<int> (W));
  vector<vector<int>> R(H, vector<int> (W));
  vector<vector<int>> U(H, vector<int> (W));
  vector<vector<int>> D(H, vector<int> (W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(data.at(i).at(j) == '#') {
        L.at(i).at(j) = 0;
      }
      else if(j == 0) {
        L.at(i).at(j) = 1;
      }
      else {
        L.at(i).at(j) = L.at(i).at(j - 1) + 1;
      }
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = W - 1; j >= 0; j--) {
      if(data.at(i).at(j) == '#') {
        R.at(i).at(j) = 0;
      }
      else if(j == W - 1) {
        R.at(i).at(j) = 1;
      }
      else {
        R.at(i).at(j) = R.at(i).at(j + 1) + 1;
      }
    }
  }
  for(int j = 0; j < W; j++) {
    for(int i = 0; i < H; i++) {
      if(data.at(i).at(j) == '#') {
        U.at(i).at(j) = 0;
      }
      else if(i == 0) {
        U.at(i).at(j) = 1;
      }
      else {
        U.at(i).at(j) = U.at(i - 1).at(j) + 1;
      }
    }
  }
  for(int j = 0; j < W; j++) {
    for(int i = H - 1; i >= 0; i--) {
      if(data.at(i).at(j) == '#') {
        D.at(i).at(j) = 0;
      }
      else if(i == H - 1) {
        D.at(i).at(j) = 1;
      }
      else {
        D.at(i).at(j) = D.at(i + 1).at(j) + 1;
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int sum = L.at(i).at(j) + R.at(i).at(j) + U.at(i).at(j) + D.at(i).at(j) - 3;
      if(sum > ans) {
        ans = sum;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 73736
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 2e5+10;
char a[N];
int main(){
    scanf("%s",a);
    int n = strlen(a);
    for (int i=0;i<n;++i){
        if (a[i] == '?')
            a[i] = 'D';
    }
    puts(a);
    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll a,b,c,x,y;
int main(){
	cin >> a >> b >> c >> x >> y;

	ll p = c * max(x * 2,y * 2);
	ll q = c * x * 2 + b * max(0ll,y - x);
	ll r = c * y * 2 + a * max(0ll,x - y);
	ll s = a * x + b * y;
	cout << min(min(p,s),min(q,r)) << 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);	
		
		String str = sc.next();
		
		String[] strs = str.split("");
		
		StringBuffer sbfirst = new StringBuffer();
		StringBuffer sbend = new StringBuffer();
		
		for(int i=0; i<2; i++) {
			sbfirst.append(strs[i]);
		}
		for(int i=2; i<4; i++) {
			sbend.append(strs[i]);
		}
		int firstint = Integer.parseInt(sbfirst.toString());
		int endint = Integer.parseInt(sbend.toString());
		
		if(firstint<=12 && endint<=12 && firstint != 0 && endint != 0) {
			System.out.println("AMBIGUOUS");
		}else if(firstint > 12 && endint>0 && endint <=12) {
			System.out.println("YYMM");
		}else if(endint >12 && firstint<=12 && firstint != 0) {
			System.out.println("MMYY");
		}else if(firstint >12 && endint == 0) {
			System.out.println("NA");
		}else if(endint >12 && firstint == 00) {
			System.out.println("NA");
		}else if(firstint <=12 && firstint !=0 && endint == 0) {
			System.out.println("MMYY");
		}else if(endint <= 12 && endint != 0 && firstint == 0) {
			System.out.println("YYMM");
		}else if(endint ==0 && firstint ==0) {
			System.out.println("NA");
		}else if(firstint >12 && endint > 12) {
			System.out.println("NA");
		}
	}
}


Measured memory_bytes: 21844
import Data.Bits
import Data.Char

solve :: [Int] -> Int -> Int
solve [] _ = 0
solve [x] _ = x
solve (x:y:xs) b
    | b .&. 1 == 1 = solve ((x*10+y):xs) (shiftR b 1)
    | otherwise = x + (solve (y:xs) (shiftR b 1))

main = do
    s <- getLine
    let bit = (2 ^ (length s - 1)) - 1
    print $ sum $ map (\b -> solve (map digitToInt s) b) [0..bit]

Measured memory_bytes: 636
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define mp make_pair
#define ll long long
#define int long long

typedef pair<int, int> ii;

priority_queue<ii> pq;

signed main() {
	fastio;
	int n; cin >> n;
	int a[n], counter[n];
	ll ans[n];
	rep(i, 0, n) {
		ans[i] = 0;
		cin >> a[i];
		counter[i] = 1;
		pq.push(mp(a[i], i));
	}
	while(pq.size() > 1) {
		ii t1, t2;
		t1 = pq.top(); pq.pop();
		t2 = pq.top(); pq.pop();
		ans[t1.second] += (ll)counter[t1.second] * (t1.first - t2.first);
		pq.push(mp(t2.first, min(t1.second, t2.second)));
		counter[min(t1.second, t2.second)] += counter[max(t1.second, t2.second)];
	}
	ans[0] += n * pq.top().first;
	rep(i, 0, n) {
		cout << ans[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 7344
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		string a, b;
		cin >> a >> b;
		ll ans = 0;
		for (ll i = 0; i < a.size(); i++)
		{
			if (a[i] != b[i])
				ans++;
		}
		cout << ans << endl;

	}
	return 0;
}


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

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

int n;

int main() {
	cin >> n;
	for (int i = 11; i <= 55555; i += 30) {
		if (isprime(i) == true) {
			if (i != 11) cout << " ";
			cout << i; n--;
		}
		if (n == 0) break;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B;
cin>>A>>B;
vector<bool>t(3);
t.at(A-1)=true;
t.at(B-1)=true;
for(int i=0; i<3; i++){
if(t.at(i)==false){
cout<<i+1<<endl;
break;
}
}
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;


int main(){

      int n;
      cin>>n;
      string s;
      cin>>s;
      int ok=0;
      int ng=n/2+1;
      //cout<<ok<<ng<<endl;
      while(ng-ok>1){
            int pos=(ok+ng)/2;
            bool good=false;
            for(int i=pos;i+pos<=n;i++){
                  string t;
                  for(int j=i;j<i+pos;j++){
                        t.push_back(s[j]);
                  }
                  if(s.find(t)+pos<=i){
                        good=true;
                  }
            }
            if(good) ok=pos;
            else ng=pos;
      }
      cout<<ok<<endl;
      return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        vector<double> v(n);
        rep(i,n)cin>>v[i];
        sort(all(v));
        rep(i,n-1)
        {
                v[i+1]=(v[i+1]+v[i])/2;
        }
        cout<<v[n-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  	int arr[n];
  	for(int i=0;i<n;i++){cin>>arr[i];}
  	int dp[n];
  	dp[0]=0;dp[1]=abs(arr[1]-arr[0]);
  	for(int i=2;i<n;i++){
    	dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i-2]-arr[i]));
    }
  	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    SORT(a);
    pr(a[0]+ a[1]);
}

Measured memory_bytes: 764
#include <iostream>
#include <stack>

int main(void){
	std::stack<int> s;int in;
	while(std::cin>>in){
		if(!in){
			std::cout << s.top() << std::endl;
			s.pop();
		}else{
			s.push(in);
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INT = 1e9;
const ll LINF = 1e18;

void solve(){
    int n,t; cin >> n >> t;
    vector<int> imos(t+1);
    for(int i = 0; i < n;i++){
        int l,r; cin >> l >> r;
        imos[l]++;
        imos[r]--;
    }
    for(int i = 1;i <= t;i++){
        imos[i] += imos[i-1];
    }
    cout << *max_element(imos.begin(), imos.end()) << endl;
}
int main(void){
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 3360
#include <bits/stdc++.h>
using ll = long long;
constexpr int MOD = 1000000007;
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  
  string a = s.substr(0, n/2);
  string b = s.substr(n/2);
  
  if (a == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
import heapq
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
ans=0
for i in range(k+1):
    tmp=a[:i]
    for j in range(k+1-i):
        if i+j>n:
            cal=a.copy()
            zan=k-n
        else:
            cal=tmp+a[n-j:]
            zan=k-i-j
        
        heapq.heapify(cal)
        ans=max(ans,sum(cal))
        for _ in range(zan):
            if len(cal)>0:
                heapq.heappop(cal)
                ans=max(ans,sum(cal))
            else:
                break
print(ans)


Measured memory_bytes: 3064
@0[@_=glob<>]=($_)x$&,@1[@_]=1..$&for<>=~/ .* /..$`;$s[$s=++$t+$']=$_,map$s[$s]+=abs$$_[$s]-$$_[$t],0,1for@s[1..9e4];/ /&&print$s[$']-$s[$`],$/for<>

Measured memory_bytes: 37632
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a)
  {
    cin >> i;
  }

  vector<bool> checked(n, false);
  int ans = 0;
  int i = 0;
  while(true){
    if(checked.at(i)){
      ans = -1;
      break;
    }
    checked.at(i) = true;
    i = a.at(i);
    i--;
    ans++;
    if(i==1){
      break;
    }
  }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define LONGMAX 1e18
#define MOD 1000000007
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(int i=a;i<n;i++)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	
	vector<int> h(n,0);
	for( int i=0;i<n;i++)
		cin>>h[i];

	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for( int i=2;i<n;i++)
	{
		dp[i]=min((dp[i-1] + abs(h[i]-h[i-1])),dp[i-2] + abs(h[i]-h[i-2]));
	}

	cout<<dp[n-1];
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		String s = in.next();
		int s_nam = s.length();
		int s_center = (s_nam-1)/2;
		char[] s_chars = s.toCharArray();
		int flag1 = 0;
		int flag2 = 0;
		int flag3 = 0;
        
        
        flag1 = gcd(0,s_nam-1,s_chars);
        flag2 = gcd(0,s_center-1,s_chars);
        flag3 =  gcd(s_center+1,s_nam-1,s_chars);

        
       if(flag1+flag2+flag3 == 0){System.out.println("Yes");}
        else{System.out.println("No");}
	}
      
      
	static int gcd(int a, int b, char[] kaibun) {
 
	    int reza = 0;
	    
        for(int i = a;i<=b; i++){
            if(kaibun[i] != kaibun[b-i] ){
                reza = 1;
            }
        }
        return reza;
	}
	
    
}
	

Measured memory_bytes: 23764