akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26180
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let a: usize = sc.read();
    let b: usize = sc.read();
    println!(
        "{}",
        *[1, 2, 3].iter().find(|&&x| x != a && x != b).unwrap()
    );
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int q;
  cin>>q;
  priority_queue<int> q1;
  priority_queue<int,vector<int>,greater<int>> q2;
  int q1sum=0,q2sum=0;
  int sum=0;

  while(q--){
    int a;
    cin>>a;
    if(a==1){
      int b,c;
      cin>>b>>c;
      sum+=c;
      if(q1.empty()){
        q1.push(b);
        q1sum+=b;
      }else if(q1.top()>b){
        q1.push(b);
        q1sum+=b;
        if(q1.size()-q2.size()>1){
          q2.push(q1.top());
          q2sum+=q1.top();
          q1sum-=q1.top();
          q1.pop();
        }
      }else if(q2.empty()||q2.top()<b){
        q2.push(b);
        q2sum+=b;
        if(q2.size()-q1.size()>0){
          q1.push(q2.top());
          q1sum+=q2.top();
          q2sum-=q2.top();
          q2.pop();
        }
      }else{
        if(q1.size()-q2.size()>0){
          q2.push(b);
          q2sum+=b;
        }else{
          q1.push(b);
          q1sum+=b;
        }
      }
    }else{
      int res=sum;
      res+=q1.size()*q1.top()-q1sum;
      res+=q2sum-q1.top()*q2.size();
//      cout<<q1sum<<' '<<q2sum<<endl;
      cout<<q1.top()<<' '<<res<<endl;
    }
//    cout<<q1.size()<<' '<<q2.size()<<' '<<q1sum<<' '<<q2sum<<endl;
  }
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 10007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 10
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    string str; cin >> str;
    
    string temp = str;
    int ret = INT_MAX;
    int t = 0;
    
    for(int i = 0; i < temp.size(); i++)
    {
        if(i % 2 == 0) // w
        {
            if(temp[i] == '1')
            {
                t += 1;
            }
        }
        else
        {
            if(temp[i] == '0')
            {
                t += 1;
            }
        }
    }
    ret = min(ret, t);
    
    t = 0;
    for(int i = 0; i < temp.size(); i++)
    {
        if(i % 2 == 1) // w
        {
            if(temp[i] == '1')
            {
                t += 1;
            }
        }
        else
        {
            if(temp[i] == '0')
            {
                t += 1;
            }
        }
    }
    ret = min(ret, t);
    
    cout << ret << endl;
    
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <bitset>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int main(){
    int n, m; cin >> n >> m;
    vector<double> a(n); rep(i, n) cin >> a[i];

    sort(all(a)); reverse(all(a));

    double sum = 0;
    rep(i, n) sum += a[i];

    if(a[m-1] >= sum/(4*m)) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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


int main()
{

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

  
    if (a == b && a == c) {
        cout << "No" << endl;

    }

    if (a == b && a != c) {
        cout << "Yes" << endl;

    }

    if (a != b && a == c) {
        cout << "Yes" << endl;
    }

    if (a != b && a != c) {
        if (b == c) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }


    return 0;

}

Measured memory_bytes: 256
//
//  main.cpp
//  project for C++
//
//  Created by 伊藤博隆 on 2020/04/17.
//  Copyright © 2020 伊藤博隆. All rights reserved.
//

#include <iostream>
#include<set>

using namespace std;
int N;


int main(){
      cin>>N;
      string Arr[N];
      set<string> S;
   
    for (int i = 0; i < N; i++) {
        cin>>Arr[i];
        S.insert(Arr[i]);
    }
    int ans = S.size();
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 25504
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,w,p; cin >> h >> w >> p;
    bool grid[6][6]; m0(grid);
    FOR(i,h)FOR(j,w){
        char a; cin >> a;
        if(a == '.') grid[i][j] = 1;
    }
    int cnt = 0;
    FOR(i,(1<<h)){
        FOR(j,(1<<w)){
            vector<bool> col(6);
            vector<bool> row(6);
            FOR(k,h) if((1<<k)&i) row[k] = 1;
            FOR(k,w) if((1<<k)&j) col[k] = 1;
            int bcnt = 0;
            FOR(n,h)FOR(m,w) if(!col[m] && !row[n] && !grid[n][m]) bcnt++;
            if(bcnt == p) cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> a[i][j];
    }
  }
  map<char, int> mp;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      mp[a[i][j]]++;
    }
  }
  if (H % 2 != 0 && W % 2 != 0)
  {
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
      if (itr->second % 2 != 0)
      {
        itr->second--;
        break;
      }
    }
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++)
  {
    if (itr->second % 2 != 0)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  int mod2 = 0;
  if (H % 2 != 0)
  {
    mod2 += W / 2;
  }
  if (W % 2 != 0)
  {
    mod2 += H / 2;
  }
  int cnt2 = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++)
    if (itr->second % 4 == 2)
      cnt2++;
  if (cnt2 > mod2)
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

//　まずすべての要素について、a～zの登場回数をmod4でカウントしておく．そして行及び列の偶数奇数で場合分けする。両方共奇数の場合はmod4 = 1 or 3の文字がちょうど1個必要。また、真ん中の文字を覗いたカウントで、mod4 = 2の文字はそれぞれ真ん中の列及び真ん中の行で使われ、ちょうどh + w - 2個必要である。残りはすべてmod4 = 0にっている必要がある。偶数の場合はすべてがmod 4 = 0になるなど、場合分けがあるがあとは同様に可能。O(HW)。


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
    fast;
    lli n,m;
    cin>>n>>m;
    lli a[n],i;
    priority_queue<lli>p;
    fr(i,n)
    {
        cin>>a[i];
        p.push(a[i]);
    }
    fr(i,m)
    {
        lli temp=p.top();
        p.pop();
        temp/=2;
        p.push(temp);
    }
    lli sum=0;
    while(!p.empty())
    {
        sum+=p.top();
        p.pop();
    }
    cout<<sum;
    
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int>A(M);
  
  for(int i = 0 ; i < M ; i++){
  	cin >> A.at(i);
  }
	int sum = 0;
  	
  for(int i = 0 ; i < M ; i++){
  	sum += A.at(i);
  }
  
  if(N >= sum){
  	cout << N - sum << endl;
  }else{
  	cout << "-1" << endl;
  }
  
}


Measured memory_bytes: 3660
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

public class Don
{
    public Don() { }
    private Reader r = new Reader();
    private static List<int> A;

    public void Solve()
    {
        var N = r.nextInt();
        var K = r.nextInt();
        var X = r.nextInt();
        var Y = r.nextInt();

        var ret = 0;
        if (N > K)
        {
            ret = X * K + Y * (N - K);
        } else
        {
            ret = X * N;
        }

        Console.WriteLine(ret);
    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

    public Reader()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length)
            return s[i++];
        var input = Console.ReadLine();
        while (input == "")
            input = Console.ReadLine();
        s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2776
N,K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
hash = {}
A.each do |a|
    hash[a] ||= 0
    hash[a] += 1
end
hash = Hash[hash.sort_by{|k,v|-v}]
cnt = 0
while K > cnt && hash.shift do
    cnt += 1
end
p hash.values.inject(:+) || 0

Measured memory_bytes: 53704
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long A, long long B, long long C, long long X){
    int count = 0;
    REP(i, A + 1) REP(j, B + 1) REP(k, C + 1)
        if (i * 500 + j * 100 + k * 50 == X) count++;
    cout << count << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    solve(A, B, C, X);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num[] = new int[3];
        num[0] = sc.nextInt();
        num[1] = sc.nextInt();
        num[2]  = sc.nextInt();
        sc.close();

        int ans = 0;
        int total[] = {0, 0, 0};
        total[0] = num[0] * 10 + num[1] + num[2];
        total[1] = num[1] * 10 + num[0] + num[2];
        total[2] = num[2] * 10 + num[0] + num[1];
        for (int i = 0; i < 3; i++) {
            if (total[i] > ans) ans = total[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
// AOJ 0056: Goldbach's Conjecture
// 2017.10.28 bal4u@uu

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

#define MAX  50000
#define SQRT 223		// sqrt(MAX)
#define HALF 2761		// prime[2760]=24989, prime[2761]=25013
char table[MAX+1], *pmax = table+MAX;
int prime[5200], sz;	// max sz = 5132 
int ans[MAX+MAX] = {0,0,0,0,1,0};
char buf[100000];

int main()
{
	int i, j;
	char *p, *pp;
	int *q;

	for (p = table+3, i = 3; i <= SQRT; p += 2, i += 2) if (!*p) {
		for (pp = p + i; pp <= pmax; pp += i) *pp = 1;
	}
	for (q = prime, i = 3; i <= MAX; i += 2) if (!table[i]) *q++ = i;
	sz = q - prime;

	for (i = 0; i < HALF; i++) for (j = i; j < sz; j++) ans[prime[i]+prime[j]]++;

	fread(p=buf, sizeof(char), sizeof(buf), stdin);
	while (1) {
		while (*p < '0') p++;
		if (*p == '0') break;
		i = 0; while (*p >= '0') i = (i<<3) + (i<<1) + (*p++ & 0xf);
		if (i & 1) putchar('1'-table[i-2]);
		else printf("%d", ans[i]);
		putchar('\n');
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<ll> l(100, 0);
    l[0]=2, l[1]=1;
    for(int i=2; i<=90; i++) l[i]=l[i-1]+l[i-2];
    cout << l[n] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define PP pair<int,int>
int H, W, N;
int ans;
vector<int> y[200010], x[200010];
int main(){
	cin >> H >> W >> N;
	ans = H;
	for(int i = 0; i < N; i++){
		int X, Y;
		cin  >> X >> Y;
		y[Y].push_back(X);
		x[X].push_back(Y);
	}
	for(int i = 1; i <= max(H, W); i++){
		sort(x[i].begin(), x[i].end());
		sort(y[i].begin(), y[i].end());
	}
	int deep = 1;
	for(int i = 1; i <= H; i++){
		auto to = lower_bound(y[deep].begin(), y[deep].end(), i);
		
		if(to != y[deep].end()){
			ans = min(*to - 1, ans);
		}
		to = lower_bound(x[i + 1].begin(), x[i + 1].end(), deep + 1);
		if(to == x[i + 1].end() || *to != deep + 1){
			deep++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s){
        cout << a-1 << ' ' << b << endl;
    }
    else{
        cout << a << ' ' << b-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt(), t = sc.nextInt();
        int[] as = new int[n], bs = new int[n];

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            as[i] = a;
            bs[i] = b;
        }

        long[][] dp1 = new long[n][t], dp2 = new long[n][t];
        for (int i = as[0]; i < t; i++) {
            dp1[0][i] = bs[0];
        }
        for (int i = as[n - 1]; i < t; i++) {
            dp2[n - 1][i] = bs[n - 1];
        }

        for (int i = 1; i < n; i++) {
            int i1 = i, i2 = n - i - 1;
            for (int j = t - 1; j >= 0; j--) {
                if (j + as[i1] < t) {
                    dp1[i1][j + as[i1]] = Math.max(dp1[i1][j + as[i1]], dp1[i1 - 1][j] + bs[i1]);
                }
                if (j + as[i2] < t) {
                    dp2[i2][j + as[i2]] = Math.max(dp2[i2][j + as[i2]], dp2[i2 + 1][j] + bs[i2]);
                }
                dp1[i1][j] = Math.max(dp1[i1][j], dp1[i1 - 1][j]);
                dp2[i2][j] = Math.max(dp2[i2][j], dp2[i2 + 1][j]);
            }
//            debug(dp1[i1]);
//            debug(dp2[i2]);
        }

        long ans = Math.max(bs[0] + dp2[1][t - 1], dp1[n - 2][t - 1] + bs[n - 1]);
//        debug(ans);
        for (int i = 1; i < n - 1; i++)
            for (int j = 0; j < t; j++) {
                ans = Math.max(ans, dp1[i - 1][j] + dp2[i + 1][t - j - 1] + bs[i]);
            }
        out.println(ans);
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

Measured memory_bytes: 181288
#include <stdio.h>
#define INF 999999999

int l[250002] = {};
int r[250002] = {};
int c ;

void merge(int *s,int n,int left,int mid,int right){

  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i = 0;i < n1;i++) l[i] = s[left + i];
  for(i = 0;i < n2;i++) r[i] = s[mid + i];

  l[n1] = INF;
  r[n2] = INF;

  i = j = 0;
  
  for(k = left;k < right;k++){
    c++;
    if(l[i] <= r[j]){
      s[k] = l[i];
      i++;
    }
    else{
      s[k] = r[j];
      j++;
    }
  }
}

void mergesort(int *s,int n,int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(s,n,left,mid);
    mergesort(s,n,mid,right);
    merge(s,n,left,mid,right);
  }
}
    
int main(){
  
  int n,i,left,right;
  int s[500000];
  c = 0;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&s[i]);

  
  left = 0;right = n;

  mergesort(s,n,left,right);

  for(i = 0;i < n;i++){
    if(i != n - 1) printf("%d ",s[i]);
    else printf("%d\n",s[i]);
  }
  printf("%d\n",c);
  return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vsort(a);
  ll sum=0;
  rep(i,n){
    sum+=a[i];
  }
  if(sum-a[n-1]>a[n-1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# C(800)
# maximize
import numpy as np
import heapq

X, Y, Z = map(int, input().split())
A_np = np.zeros(X+Y+Z, dtype='int')
B_np = np.zeros(X+Y+Z, dtype='int')
C_np = np.zeros(X+Y+Z, dtype='int')

for i in range(X+Y+Z):
    a, b, c = map(int, input().split())
    A_np[i] = a
    B_np[i] = b
    C_np[i] = c
    
# Bronze -> Gold
order_A_C = np.argsort(A_np - C_np)
A_np_s = A_np[order_A_C]
B_np_s = B_np[order_A_C]
C_np_s = C_np[order_A_C]

# base : Bronze -> Silver -> Gold
res_base = C_np_s[:Z].sum() + B_np_s[Z:(Z+Y)].sum() + A_np_s[(Z+Y):].sum()

# left_diff_heap
C_B_heapq = list(C_np_s[:Z] - B_np_s[:Z])
heapq.heapify(C_B_heapq)

plus_left = np.zeros(Y+1, dtype='int')
for k in range(Y):
    r = heapq.heappushpop(C_B_heapq, C_np_s[Z+k] - B_np_s[Z+k])
    plus_left[k+1] = plus_left[k] - r + C_np_s[Z+k] - B_np_s[Z+k]

# right_diff_heap
A_B_heapq = list(A_np_s[(Z+Y):] - B_np_s[(Z+Y):])
heapq.heapify(A_B_heapq)

plus_right = np.zeros(Y+1, dtype='int')
for k in range(Y):
    r = heapq.heappushpop(A_B_heapq, A_np_s[Z+Y-1-k] - B_np_s[Z+Y-1-k])
    plus_right[Y-k-1] = plus_right[Y-k] - r + A_np_s[Z+Y-1-k] - B_np_s[Z+Y-1-k]
    
print((plus_left+plus_right).max() + res_base)

Measured memory_bytes: 22348
fun numOfexp2(num:Long) :Long {
    var n = 0L
    var number = num
    while (number % 2 == 0L) {
        n += 1
        number /= 2
    }
    return n
    
}
// fun numOfexp2(num:Long) = Math.floor(Math.log(num.toDouble())/Math.log(2.0)).toLong()

fun main(args:Array<String>) {
    val N = readLine()!!.toInt()
    val a_series = readLine()!!.split(" ").map(String::toLong)
    // val odd_list = a_series.filter { it % 2 == 1 }
    val even_list = a_series.filter { it % 2 == 0L }
    if(even_list.size == 0) {
        println(0)
        return
    }

    when(even_list.size) {
        0 -> 0
        else -> {
            // val min_even = even_list.minBy{numOfexp2(it)}!!
            // val max_even = even_list.maxBy{numOfexp2(it)}!!
            // // 2*numOfexp2(max_even)-numOfexp2(min_even)
            // numOfexp2(max_even)
            even_list.map {it-> numOfexp2(it)}.fold(0L) {sum,ele -> sum+ele}
        }
    }.let(::println)

}

Measured memory_bytes: 41616
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int x;
cin>>x;
x=x%10;
if(x==3)
{
    cout<<"bon"<<endl;
}
else if(x==0||x==1||x==6||x==8)
{
    cout<<"pon"<<endl; 
}
else
    cout<<"hon"<<endl;
    return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		//var n=sc.I;
		var s=sc.Ia;
		var a=sc.Ia;
		int ans=1,p=0;
		for(int i = 0;i<s[0];i++) {
			p+=a[i];
			if(p>s[1]){break;}
			ans++;
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
I = input().split()
n = int(I[0])
m = int(I[1])
l = int(I[2])

a = [[0 for i2 in range(m)] for i1 in range(n)]
b = [[0 for i2 in range(l)] for i1 in range(m)]
c = [[0 for i2 in range(l)] for i1 in range(n)]

for i in range(n):
    A = input().split()
    for j in range(m):
        a[i][j] = int(A[j])

for i in range(m):
    B = input().split()
    for j in range(l):
        b[i][j] = int(B[j])

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
        print(str(c[i][j]), end = '')
        if j != l - 1:
            print(' ', end = '')
    print()

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n;
  cin >> n;
  int v[100],c[100];
  rep(i,n){
    cin >> v[i];
  }
  rep(i,n){
    cin >> c[i];
  }
  int dp[100]={};
  dp[0] = max(0,v[0]-c[0]);
  reps(i,1,n){
    dp[i] = max(dp[i-1],dp[i-1]+v[i]-c[i]);
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n, k;
    cin >> n >> k;
    V<int> a(n);
    int idx = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 1) idx = i;
    }
    cout << (n - 1 + k - 2)  / (k - 1) << endl;
    return 0;
}


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

#define ll long long int
#define pb push_back
#define f(i,x,y) for(i=x;i<y;i++)
#define vll vector<ll>
#define fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

void solve()
{
    ll n,i;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    f(i,0,n)
    {
        cin>>v[i].first>>v[i].second;
    }
    ll f=0;
    f(i,0,n-2)
    {
        if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
        {
            cout<<"Yes"<<endl;
            return ;
        }
    }
    cout<<"No"<<endl;

}

int main()
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

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

const int MOD = 1000000007;

bool isPrime(int n) {
    int c = sqrt(n);

    if (n == 2 || n == 3 || n == 5) {
        return true;
    }

    for (int i = 2; i <= c+1; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

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

    int s = X;
    while(!isPrime(s)) {
        s++;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

map<ll,ll> M;

int main(){
  vector<ll> V;
  ll N,K,C=0,A;cin>>N>>K;
  rep(i,N){
    cin >> A;
    M[A]++;
  }
  for(auto P : M){
    if(P.second>0){
     V.push_back(P.second);
    }
  }
  sort(ALL(V));
  A=V.size();
  rep(i,(A-K>0 ? A-K : 0)){
    C+=V[i];
  }
  cout << C << endl;
}

Measured memory_bytes: 14964
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(y+r>H||x+r>W||r+y<=0||r+x<=0){
    printf("No\n");
    }
    else printf("Yes\n");
}

Measured memory_bytes: 1816
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  sort(a.begin(), a.end());

  int ans = 0, prev = a[0];
  rep(i, 1, a.size()) {
    if (a[i] == prev) continue;
    ans += a[i] - prev;
    prev = a[i];
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;
  // connect[i] := i番目のスイッチに繋がっている電球
  vector<vector<int>> connect(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      connect[s].push_back(i);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++)
    cin >> p[i];

  int ans = 0;
  for (int b = 0; b < (1 << n); b++) {
    vector<int> cnt(m, 0);
    for (int i = 0; i < n; i++) {
      if (!(~b & (1 << i)))
        continue;
      for (auto e : connect[i]) {
        cnt[e]++;
        cnt[e] %= 2;
      }
    }
    if (equal(p.begin(), p.end(), cnt.begin(), cnt.end()))
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3668
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	char s[201];
	bool isExist;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 2; i < len; i += 2) {
		isExist = true;
		for (int j = 0; j < (len - i) / 2; j++) {
			if (s[j] != s[(len - i) / 2 + j]) {
				isExist = false;
				break;
			}
		}
		if (isExist) {
			printf("%d\n", len - i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


ll f(ll a,ll b){
  ll ans = 0;

  if (b%2 == 0){
    ans = (b/2)%2 ^ b;
  }else{
    ans = (b+1)/2%2;
  }


  return ans;
}


int main() {
  ll a,b;
  cin >> a >>b;


  ll ans = 0;

  ll a1 = a-1;
  ll b1 = b;

  // cerr << ans <<"  :  " <<ans2 <<endl;


  ans = f(0,a1)^f(0,b1);



  cout << ans << endl;

}




















Measured memory_bytes: 256
from sys import stdin

n = int(input())
s = [stdin.readline().rstrip().split() for i in range(n-1)]

def kaisuu(s,i):
    t = int(s[i][0]) + int(s[i][1])
    if i != n-1:
        for j in range(i+1,n-1):
            if  t <= int(s[j][1]):
                t = int(s[j][0]) + int(s[j][1])
            elif t % int(s[j][2]) == 0:
                t = t + int(s[j][0])
            else:
                t = t + int(s[j][0]) + (int(s[j][2]) - t % int(s[j][2]))
    return t

for i in range(0,n-1):
    print(kaisuu(s,i))

print(0)

Measured memory_bytes: 3188
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext())
			{
				long a = sc.nextInt();
				long b = sc.nextInt();
				long d = a * b; 
				long r;
					for(;;)
					{
						r = a % b;if(r==0){System.out.println(b +" "+ d/b);break;}
						a = b % r;if(a==0){System.out.println(r +" "+ d/r);break;}
						b = r % a;if(b==0){System.out.println(a +" "+ d/a);break;}
					}
			}
	}
}

Measured memory_bytes: 17360
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
const int MOD = 1e9 + 7 ;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int32_t main(){
   IOS
   int n;
   cin>>n;
   int k;
   cin>>k;
   vector<int>arr(n);
   for (int &x : arr)
       cin>>x;

   vector<int>dp(n,INT_MAX);
   dp[0]=0;
    for (int i = 0; i < n; ++i) {
        for( int j =i+1; j<=k+i;j++){
                if(j<n) dp[j] = min(dp[j],dp[i] + abs(arr[i]-arr[j]));
        }
    }
   cout<<dp[n-1]<<endl;


    return 0;
}
// CHECK FOR CORNER CASES LIKE 0,1 etc.


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

int main()
{
  int n,k,c[100];
  while(cin>>n>>k,n|k){
    for(int i=0;i<n;i++)cin>>c[i];

    int original=-1;
    for(int i=0;i<n-k+1;i++){
      int product=1;
      for(int j=0;j<k;j++){
	product *= c[i+j];
      }
      original=max(original,product);
    }

    int C=-1;
    for(int s=0;s<n-1;s++){
      for(int t=s+1;t<n;t++){
	swap(c[s],c[t]);
	for(int i=0;i<n-k+1;i++){
	  int product=1;
	  for(int j=0;j<k;j++){
	    product *= c[i+j];
	  }
	  C=max(C,product);
	}
	swap(c[s],c[t]);
      }
    }

    if(original>C)puts("NO GAME");
    else cout<<C-original<<endl;
  }
}

Measured memory_bytes: 864
import math
from functools import reduce
     
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
     
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
      
N = int(input())
A = list(map(int,input().split()))
ans = 0
     
lcm = lcm_list(A)
     
for i in range(N):
    ans += lcm//A[i]
     
print(ans%1000000007)

Measured memory_bytes: 10544
import java.io.*;

class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true){
			String line[] = br.readLine().split(" ");
			int x = Integer.parseInt(line[0]);				
			int y = Integer.parseInt(line[1]);
			if(x == 0 && y == 0){
				break;
			}
			else{
				sb.append(Integer.toString(x < y ? x : y)).append(" ").append(Integer.toString(x < y ? y : x)).append("\n");
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 26472
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, x, m = map(int,input().split())
    sum_lis = [-1] * m #余りが最初にiのときの和
    a_lis_i = [-1] * m #余りが最初にiのときのindex
    a = x
    sum_a = a
    sum_lis[a] = sum_a
    a_lis_i[a] = 0
    for i in range(1, n):
        a = pow(a, 2, m)
        sum_a += a
        if sum_lis[a] != -1: #2週目
            loop_i = i - a_lis_i[a] #1循環の個数
            loop_sum = sum_a - sum_lis[a] #1循環の和
            loop_cunt = (n - 1 - i)//loop_i #i+1以降の循環個数
            sum_a += loop_sum*loop_cunt #ループ分まとめて足す
            i += loop_i*loop_cunt
            for j in range(i + 1, n):
                a = pow(a, 2, m)
                sum_a += a             
            print(sum_a)
            sys.exit()
        sum_lis[a] = sum_a
        a_lis_i[a] = i
    print(sum_a)

if __name__=='__main__':
    main()

Measured memory_bytes: 65692
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        if(abs(a-b)>abs(a-c))
            printf("B\n");
        else
            printf("A\n");
    }
}


Measured memory_bytes: 128
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"
 
#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
typedef long long ll;
using namespace std;

int n;
ll cnt,a[50],p;
bool b;

int main(){
	cin>>n;
	rep(n)
		cin>>a[i];
	cnt=p=0;
	b=true;
	while(b){
		b=false;
		rep(n){
			if((a[i]-p)/n){
				b=true;
				cnt+=(a[i]-p)/n;
				a[i]-=(a[i]-p)/n*(n+1);
				p=-cnt;
			}
		}
	}
	cout<<cnt<<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);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();
		
		long ans = Math.max(a*c, Math.max(a*d, Math.max(b*c, b*d)));
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 35696
def f(a, n):
    b = []
    minA = min(a)
    b.append(minA)
    for i in range(n):
        if a[i] % minA != 0:
           b.append(a[i] % minA)
    if len(b) == 1:
        print(b[0])
        exit()
    else:
        f(b,len(b))

n = int(input())
a = list(map(int, input().split()))
f(a, n)


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

class UnionFind
{
public:
    vector<long long> root;

    UnionFind(long long N)
    {
        this->root = vector<long long>(N + 1, -1);
    }

    long long find_root(long long A)
    {
        if (this->root[A] < 0)
        {
            return A;
        }
        else
        {
            this->root[A] = find_root(this->root[A]);
        }
        return this->root[A];
    }

    long long size(long long A)
    {
        return -this->root[find_root(A)];
    }

    bool unite(long long A, long long B)
    {
        A = find_root(A);
        B = find_root(B);
        if (A == B)
        {
            return false;
        }

        if (size(A) < size(B))
        {
            swap(A, B);
        }

        this->root[A] += this->root[B];
        this->root[B] = A;

        return true;
    }

    bool has_same_root(long long A, long long B)
    {
        return find_root(A) == find_root(B);
    }
};

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

    vector<int> ans(N + 1, 0);

    UnionFind uf(N);
    vector<set<int>> fr(N + 1);
    int A, B;
    for (int i = 0; i < M; i++)
    {
        cin >> A >> B;
        uf.unite(A, B);
        fr[A].insert(B);
        fr[B].insert(A);
    }

    vector<set<int>> bl(N + 1);
    int C, D;
    for (int i = 0; i < K; i++)
    {
        cin >> C >> D;
        if (fr[C].count(D) > 0)
        {
            ans[C]++;
        }
        if (fr[D].count(C) > 0)
        {
            ans[D]++;
        }

        if (uf.has_same_root(C, D))
        {
            ans[C]--;
            ans[D]--;
        }
        bl[C].insert(D);
        bl[D].insert(C);
    }

    for (int i = 1; i <= N; i++)
    {
        ans[i] += uf.size(i) - fr[i].size();
        cout << ans[i] - 1 << endl;
    }
}


Measured memory_bytes: 30080
x, n = map(int, input().split())
p = list(map(int, input().split()))
p.sort()


def ans():
    if n == 0:
        return x
    for i in range(100):
        if x - i not in p:
            return x-i
        if x + i not in p:
            return x+i


print(ans())

Measured memory_bytes: 9204
import math
a=input()
b=input()
c=input()
if int(a)>int(b):
 print(math.ceil(int(c)/int(a)))
elif int(a)<int(b):
 print(math.ceil(int(c)/int(b)))
elif int(a)==int(b):
 print(math.ceil(int(c)/int(b)))


Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
int *S;
int n;


void partition(int p,int r){
	int i = -1;
	int j = -1;
	for(int k = 0;k < n-1;k++){
		if(S[k] <= S[r]){
			if(i == j){
				i++;
				j++;
			}else{
				swap(S[k],S[i+1]);
				i++;
				j++;
			}
		}else{
			j++;
		}
	}
	swap(S[r],S[i+1]);
	for(int l = 0;l < n;l++){
		if(l == i+1){
			cout << "[" << S[l] <<"] ";
		}else if(l == n-1){
			cout << S[l] << endl;
		}else{
			cout << S[l] << " ";
		}
	}
}

int main(){
	cin >> n;
	S = new int[n];
	for(int i = 0;i < n;i++) cin >> S[i];

	partition(0,n-1);
	return 0;
}

Measured memory_bytes: 1568
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a, b;
  cin>>a>>b;
  if(a==b){
    cout<<"Draw"<<endl;
  }else if(a==1){
    cout<<"Alice"<<endl;
  }else if(b==1){
    cout<<"Bob"<<endl;
  }else if(a>b){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Bob"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int dx[3] = {-1,+1, 0};
int dy[3] = {-1,+1, 0};
int main()
{
  int h, w;
  cin >> h >> w;
  vector<string > a(h, "");
  REP(i,h){
    cin >> a[i];
  }
  // REP(i,h){
  //   cout << a[i] << endl;
  // }
  REP(i,h){
    REP(j,w){
      if(a[i][j] == '.'){
	int y = 0;
	int x = 0;
	int count = 0;
	REP(k,3){
	  x = i + dx[k];
	  if(0 <= x && x <= h - 1){
	    REP(l,3){
	      y = j + dy[l];
	      if(0 <= y && y <= w - 1){
		if(a[x][y] == '#'){
		  count ++;
		}
	      }
	    }
	  }
	}
	a[i][j] = '0' + count;
      }
    }
  }
  REP(i,h){
    cout << a[i] << endl;
  }
}


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

int main()
{
  int s;
  cin >> s;
  int ans = 0, sum = 0, m = 0;
  int a[s];
  rep(i, s) {
    cin >> a[i];
  	m = max(m, a[i]);
    sum += a[i];
  }
  cout << sum - m + m / 2 << endl;
  return 0;
}

Measured memory_bytes: 3668
x1, y1, x2, y2 = [int(_) for _ in input().split()]
p = (x1 + x2 + y1 - y2) / 2
q = (x2 - x1 + y2 + y1) / 2
v = x1 - p
u = y1 - q
x3, y3 = int(p - v), int(q - u)
x4, y4 = int(p + u), int(q - v)
print(x3, y3, x4, y4)

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

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

    if (a * b == 15) cout << "*" << endl;
    else if (a + b == 15) cout << "+" << endl;
    else cout << "x" << endl;

    return 0;
}


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

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

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

const ll INF = 1LL << 60;

ll h[100010];

ll dp[100010];

ll rec(int i){
    if(dp[i] < INF) return dp[i];
    
    if(i == 0) return 0;
    
    ll res = INF;
    
    chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
    if(i > 1) chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));
    
    return dp[i] = res;
}


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    rep(i,n) cin >> h[i];
    
    rep(i,100010) dp[i] = INF;
    
    cout << rec(n - 1) << endl;

}


Measured memory_bytes: 6528
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_nested(i, s, n) for (int i = s; i <= n; i++)
#define ll long long
#define ull unsigned long long

const int N = 500;
const ll INF = 1000000007;

using namespace std;

template <class T>
T limit(T n, T k) {
	return (n > k) ? k : n;
}

template <class T>
T has_order(T a, T b, T c) {
	return (b > a && b < c) || (b < a && b > c);
}

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

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

#define YES "Yes"
#define NO "No"

int main()
{
    long long int d, t, s;

    scanf("%lld %lld %lld", &d, &t, &s);

    if (d <= (t*s))
    {
        printf("%s", YES);
    } else {
        printf("%s", NO);
    }

    return 0;
}

Measured memory_bytes: 1736