akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int mxn = 100005, mxm = 200005;
int n, m, l[mxm], r[mxm], d[mxm];
ll loc[mxn];
bool seen[mxn];
vector<pair<int, int>> adj[mxn];

bool dfs(int node){
    for(auto& p : adj[node]){
        int next = p.F, dist = p.S;
        if(seen[next]){
            if(loc[next] != loc[node] + dist) return false;
        }
        else{
            seen[next] = true;
            loc[next] = loc[node] + dist;
            if(!dfs(next)) return false;
        }
    }
    return true;
}

void solve(){
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        cin >> l[i] >> r[i] >> d[i];
        --l[i], --r[i];
        adj[l[i]].push_back({r[i], d[i]});
        adj[r[i]].push_back({l[i], -d[i]});
    }

    for(int i = 0; i < n; ++i){
        if(!seen[i]){
            seen[i] = true;
            if(!dfs(i)){
                cout << "No\n";
                return;
            }
        }
    }

    ll mi = 1e18, mx = -1e18;
    for(int i = 0; i < n; ++i){
        mi = min(mi, loc[i]);
        mx = max(mx, loc[i]);
    }
    if(mx - mi <= 1e9){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

using namespace std;
#define int long long 
#define N 666666
int arr[N],a[N],b[N];
signed main(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import collections
m = int(input())
n = 1000000000
ans = []
listnum = [
            [0, 1],
            [0, 1, 2],
            [1, 2, 3],
            [2, 3, 4],
            [3, 4, 5],
            [4, 5, 6],
            [5, 6, 7],
            [6, 7, 8],
            [7, 8, 9],
            [8, 9]
           ]
def dfs(s):
    if len(str(n)) + 1 > len(s):
        ans.append(int(s))
        lastnum = str(s)[-1]
        for i in listnum[int(lastnum)]:
            dfs(s + str(i))
for i in range(1, 10):
    dfs(str(i))
ans = sorted(ans)
print(ans[m - 1])

Measured memory_bytes: 83676
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, t;
	cin >> a >> b >> t;
	cout << b * (t / a) << '\n';
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();    
    int total = 0, min =1000;
    for (int i=0; i<N; i++) {
      int m = sc.nextInt();
      X -= m;
      min = Math.min(m,min);
      total++;
    } 
    System.out.println(total + X / min); 
  }
}

Measured memory_bytes: 21204
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	ll sum = 0;
	cin >> n;
	vector<ll>spot(n), diff(n + 1);
	rep(i, n)cin >> spot[i];
	sum += abs(spot[0]);
	diff[0] = abs(spot[0]);
	rep(i, n - 1) {
		diff[i + 1] = abs((5000 + spot[i + 1]) - (5000 + spot[i]));
		sum += diff[i + 1];
	}
	diff[n] = abs(spot[n - 1]);
	sum += diff[n];
	rep(i, n) {
		if (i == 0) {
			//sum -= (diff[0] + diff[1]);
			cout << sum + abs(spot[1]) - (diff[0] + diff[1]) << endl;
		}
		else if (i == n - 1) {
			//sum -= (diff[n - 1] + diff[n]);
			cout << sum + abs(spot[n - 2]) - (diff[n - 1] + diff[n]) << endl;;
		}
		else {
			//sum -= (diff[i] + diff[i + 1]);
			cout << sum + abs(spot[i - 1] - spot[i + 1]) - (diff[i] + diff[i + 1]) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4848
#include<iostream>
#include<stdio.h>
#include<string.h>
#define P 1000000007
#define N 3200
using namespace std;
long long f[N][N];
long long inv2;
int n,q,a[N];
long long power(long long x,int k){
	long long ans=1;
	while(k){
		if(k&1)(ans*=x)%=P;
		(x*=x)%=P;
		k>>=1;
	}
	return ans;
}
int main(){
	inv2=power(2,P-2);
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(a[i]==a[j])continue;
			if(a[i]<a[j])f[i][j]++;
			if(a[j]<a[i])f[j][i]++;
		}
	}
	for(int i=1;i<=q;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==y)continue;
		long long tmp=(f[x][y]+f[y][x])*inv2%P;
		f[x][y]=tmp;
		f[y][x]=tmp;
		for(int i=1;i<=n;i++){
			if(i==x||i==y)continue;
			long long tmp=(f[x][i]+f[y][i])*inv2%P;
			f[x][i]=tmp;
			f[y][i]=tmp;
			tmp=(f[i][x]+f[i][y])*inv2%P;
			f[i][x]=tmp;
			f[i][y]=tmp;
		}
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)(ans+=f[i][j])%=P;
	printf("%lld\n",ans*power(2,q)%P);
} 

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

class Main{
    public static void main(String[] args){
        int count;
        int[] array = new int[100];
        int key;
        int mini = 0;
        int counter = 0;

        try{
            Scanner scan = new Scanner(System.in);
            String str = scan.next();

            count = Integer.parseInt(str);

            for(int i = 0; i < count; i++){
                str = scan.next();
                array[i] = Integer.parseInt(str);
            }

            //Sort Part
            for(int i = 0; i < count - 1; i++){
                mini = i;
                for(int j = i; j < count; j++){
                    if(array[j] < array[mini]){
                        mini = j;
                    }
                    // key = array[mini];
                    // array[mini] = array[i];
                    // array[i] = key;
                }
                if(mini != i){
                    key = array[mini];
                    array[mini] = array[i];
                    array[i] = key;
                    counter++;
                }
            }

            for(int i = 0; i < count; i++){
                if(i == count - 1){
                    System.out.println(array[i]);
                }else{
                    System.out.print(array[i] + " ");
                }
            }

            System.out.println(counter);

        }catch(Exception e){
            System.out.println("ERROR");
        }

    }
}



Measured memory_bytes: 26372
import numpy as np
n,m,c=map(int,input().split())
b=np.array(list(map(int,input().split())))
a=[]
count=0
for i in range(n):
    a.append(list(map(int,input().split())))
na=np.array(a)
nab=np.dot(na,b)
for j in range(n):
    if nab[j]>-c:
        count+=1
        j+=1
print(count)

Measured memory_bytes: 12424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,a,b;
  cin>>N>>M;
  vector <int> vec(N);
  for (int i=0;i<M;i++){
    cin>>a>>b;
    vec.at(a-1)=vec.at(a-1)+1;
    vec.at(b-1)=vec.at(b-1)+1;
  }
  for (int i=0;i<N;i++){
    cout<<vec.at(i)<<endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
p = {} #各点と繋がってる点を記録
for _ in range(M):
    a, b = map(int, input().split())
    if a in p:
        p[a].append(b)
    else:
        p[a] = [b]
    if b in p:
        p[b].append(a)
    else:
        p[b] = [a]
cnt = 0 #答え
def func(q, l, n): #q今いる点 lこれまで訪れた点のリスト nこれまで訪れた頂点の種類
    if n == N:
        global cnt
        cnt += 1
    for i in p[q]:
        if i not in l: #今まで訪れてなければ訪れる
            func(i, l+[i], n+1)
func(1, [1], 1)
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  while(true){
    int m,f,r; cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) break;
    if(m == -1 || f == -1) cout << 'F' << endl;
    else if(m+f >= 80) cout << 'A' << endl;
    else if(m+f >= 65) cout << 'B' << endl;
    else if(m+f >= 50) cout << 'C' << endl;
    else if(m+f >= 30){
      if(r >= 50) cout << 'C' << endl;
      else cout << 'D' << endl;
    }else cout << 'F' << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
class Simple {
    private long N, A, B;
    private long[] h;
    void Solve() {
        //input
        N = io.Int;
        A = io.Int;
        B = io.Int;
        h=new long[N];
        for(int i = 0; i < N; ++i) h[i] = io.Int;
        //cal
        var diff = A - B;
        Func <long, bool> isOK = (num) => {
            var damaged = B * num;
            var addNum = 0L;
            for(int i = 0; i < N; ++i) {
                var left = h[i] - damaged;
                if(left > 0) addNum += left / diff + (left % diff == 0 ? 0 : 1);
            }            
            return addNum<=num;
        };
        var ans = binarySearch(h, -1, (long)1e9 + 5, isOK);
        //ret
        Console.WriteLine(ans);            
    }

    long binarySearch(long[] a, long ng, long ok, Func <long, bool> check) {
        while(ok - ng > 1) {
            long mid = (ok + ng) / 2;
            if(check(mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
    
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] {' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

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

int main() {
    int N;
    cin >> N;
    string s;
    map<string, int> m;
    for (int i = 0; i < N; i++) {
        cin >> s;
        m[s]++;
    }
    int max_n = 0;
    for (auto i = m.begin(); i != m.end(); i++) {
        max_n = max(max_n, i->second);
    }
    for (auto i = m.begin(); i != m.end(); i++) {
        if (i->second == max_n) cout << i->first << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll x,y;
    cin >> x >> y;
    if(y-2*x>=0 && (y-2*x)%2==0 && x-(y-2*x)/2>=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())
		cout<<"GREATER"<<endl;
    else if(a.size()<b.size())
		cout<<"LESS"<<endl;
    else if(a>b)
    cout<<"GREATER"<<endl;
    else if(a<b)
    cout<<"LESS"<<endl;
    else if(a==b)
    cout<<"EQUAL"<<endl;    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    (t>s)? cout << "Yes" << endl : cout << "No" << endl;

    return 0;
}

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

class Main {
  int N;
  int[] d;
  Integer[] D;
  int count;
  public static void main(String[] args) {
    Main m = new Main();
    m.input();
    m.solve();
    m.out();
  }

  public void input() {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    d = new int[N];
    for(int i = 0; i < N; i++) {
      d[i] = sc.nextInt();
    }
    sc.close();
  }

  public void solve() {
    D = new Integer[N];
    for(int i = 0; i < N; i++) {
      D[i] = Integer.valueOf(d[i]);
    }
    Arrays.sort(D, Comparator.reverseOrder());
    count = 1;
    for(int i = 1; i < N; i++) {
      if(D[i] == D[i - 1]) {
        continue;
      } else {
        count++;
      }
    }
  }

  public void out() {
    System.out.println(count);
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
 
#define NMAX 100001
#define MAX(a, b) (a > b ? a : b)
 
using namespace std;
 
//ifstream fin("f.in");
//ofstream fout("f.out");
 
struct Restaurant {
    char name[11];
    int score;
    int order;
};
 
int n;
Restaurant restaurants[101];
 
 
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> restaurants[i].name >> restaurants[i].score;
        restaurants[i].order = i;
    }
    for(int i = 1; i < n; i++)
        for(int j = i + 1; j <= n; j++)
        {
            if(strcmp(restaurants[i].name, restaurants[j].name) == 0)
            {
                if(restaurants[i].score < restaurants[j].score)
                    swap(restaurants[i], restaurants[j]);
            }
            else if(strcmp(restaurants[i].name, restaurants[j].name) > 0)
                swap(restaurants[i], restaurants[j]);
        }
    for(int i = 1; i <= n; i++)
        cout << restaurants[i].order << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
         if(n<k){
            n = Math.min(n,k-n);
        }
        long ans = n;
       
        if(k<=n) ans = Math.min(n%k,k-(n%k));
        System.out.println(ans);
       
     }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    bitset<40> bs(0);

    rep(i, 40) {
        if (i == 0) {
            ll ai = a, bi = b;
            if (ai % 2 == 0) ai++;
            if (bi % 2 == 1) bi++;
            bs[i] = ((bi - ai + 1) / 2) % 2;
            continue;
        }

        ll x = a % (1LL << (i + 1));
        ll y = b % (1LL << (i + 1));
        ll r = 0;

        if (x <= y) {
            if (y < (1LL << i)) r = 0;
            else if (x >= (1LL << i)) r = y - x + 1;
            else r = y - (1LL << i) + 1;
        } else {
            r += (1LL << (i + 1)) - max(x, (1LL << i));
            if (y >= (1LL << i)) r += y - (1LL << i) + 1;
        }


        if (r % 2 == 1) {
            bs[i] = 1;
        } else {
            bs[i] = 0;
        }
    }
    cout << bs.to_ulong() << endl;
    return 0;
}

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

int main(){
    int H,R;

    cin >> H >> R;

    if(H>=0){
        cout << 1 << endl;
    }else{
        if(H==-R){
            cout << 0 << endl;
        }else if(-H<R){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3092
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		long num = 333;
		int cnt = 0;
		while(num <= N) {
			cnt++;
			boolean flag[] = new boolean[3];
			String str = String.valueOf(num);
			for(int i = 0; i < str.length(); i++) {
				if(str.substring(i, i + 1).equals("3")) flag[0] = true;
				if(str.substring(i, i + 1).equals("5")) flag[1] = true;
				if(str.substring(i, i + 1).equals("7")) flag[2] = true;
			}
			if(flag[0] && flag[1] && flag[2]) ans++;
			
			if(cnt % 3 == 0) {
				String new_num = "";
				boolean up = false;
				for(int i = 0; i < str.length(); i++) {
					if(str.substring(str.length() - i - 1, str.length() - i).equals("7")) {
						new_num = "3" + new_num;
						if(i == str.length() - 1) {
							new_num = "3" + new_num;
						}
						up = true;
					} else {
						new_num = str.substring(0, str.length() - i - 1) +  String.valueOf(Integer.parseInt(str.substring(str.length() - i - 1, str.length() - i)) + 2) + new_num;
						break;
					}
				}
				num = Long.parseLong(new_num);
			} else {
				num += 2;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 44980
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
d = {}
for n in A:
    if n in d.keys():
        d[n] += 1
    else:
        d[n] = 1
if len(d.keys()) <= K:
    print(0)
else:
    val = []
    for k, v in sorted(d.items(), key=lambda x: -x[1]):
        val.append(v)
    ans = 0
    for i in val[K:]:
        ans += i
    print(ans)


Measured memory_bytes: 39760
<?php
fscanf(STDIN, "%d%d%d", $n, $A, $B);
$a = 0; $b = 0;
$s = trim(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  if($s[$i] == "a"){
    if($a+$b < $A+$B){
      $ans[] = "Yes";
      $a++;
    }else{
      $ans[] = "No";
    }
  }elseif($s[$i] == "b"){
    if($a+$b < $A+$B && $b < $B){
      $ans[] = "Yes";
      $b++;
    }else{
      $ans[] = "No";
    }
  }else{
    $ans[] = "No";
  }
}
echo implode("\n", $ans),"\n";


Measured memory_bytes: 11124
import java.util.Scanner;

public class Main {
	public static int cnt = 0;
	public static int m = 0;
	public static int[] sortedArray = new int[100];

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

		int num = scan.nextInt();
		int[] array = new int[num];
		for (int i = 0; i < num; i++) {
			array[i] = scan.nextInt();
		}
		shellSort(array, num);

		// output
		System.out.println(m);
		//shellsortでm-1から入力しているのでm-1から出力していく
		System.out.print(sortedArray[m - 1]);
		for (int i = m - 2; i >= 0; i--) {
			System.out.print(" " + sortedArray[i]);
		}
		System.out.println();
		System.out.println(cnt);
		for (int i = 0; i < num; i++) {
			System.out.println(array[i]);
		}
		System.out.println();
		
		scan.close();

	}

	/**
	 * 挿入ソート
	 * 
	 * @param sortArray：オリジンの配列
	 * @param num：要素の個数
	 * @param g: スタート位置
	 */
	public static void insertionSort(int[] sortArray, int num, int initialStatePoint) {

		for (int i = initialStatePoint; i < num; i++) {
			int v = sortArray[i]; // 1枚取り出す
			int j = i - initialStatePoint;
			while (j >= 0 && sortArray[j] > v) {// 取り出した一枚より前の方に持っていたカードと比較
				sortArray[j + initialStatePoint] = sortArray[j];
				j = j - initialStatePoint;
				cnt++;
			}
			sortArray[j + initialStatePoint] = v;

		}

	}

	/**
	 * シェルソート
	 * @param sortArray オリジンの配列
	 * @param num：要素の個数
	 */
	public static void shellSort(int[] sortArray, int num) {
		for (int i = 1;; i = i * 3 + 1) {
			if (i > num) {
				break;
			}
			sortedArray[m] = i;		
			m++;
		}
		for (int i = m - 1; i >= 0; i--) {
			insertionSort(sortArray, num, sortedArray[i]);
		}
	}

}



Measured memory_bytes: 300756
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    int N;
    std::cin >> N;
    std::array<std::vector<int>, 2> map = {std::vector<int>(N, 0), std::vector<int>(N, 0)};
    for(auto& val:map[0])
        std::cin >> val;
    for(auto& val:map[1])
        std::cin >> val;

    for(int i = 1; i < N; ++i) {
        map[0][i] += map[0][i - 1];
    }

    for(int i = N - 2; i >= 0; --i) {
        map[1][i] += map[1][i + 1];
    }

    int ans = 0;
    for(int i = 0; i < N; ++i) {
        ans = std::max(ans, map[0][i] + map[1][i]);
    }

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


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

int main() {
  int n, a, b, ans = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int num = i/10000 + i%10000/1000 + i%1000/100 + i%100/10 + i%10;
    if (num >= a && num <= b)
      ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))


class BTwoColorsCardGame {
public:
	void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    vector<string> s(n);
    REP(i,n) in >> s[i];

    int m;
    in >> m;
    vector<string> t(m);
    REP(i,m) in >> t[i];

    map<string, int> a;
    REP(i,n){
      a[s[i]]++;
    }
    REP(i,m){
      a[t[i]]--;
    }
    out << max(0ll, max_element(a.begin(),a.end(),[](pair<string, int> b, pair<string, int> c){return b.second < c.second;})->second) << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	BTwoColorsCardGame solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
int x;
int a[323456];
bool b[323456];

int main(){
	scanf("%d%d" , &N, &x);
	if(x == 1 || x == 2 * N - 1){
		printf("No\n");
	} else {
		printf("Yes\n");
		a[N] = x;
		b[x] = 1;
		if(x < N){
			a[N+1] = 1;
			b[1] = 1;
			a[N-1] = 2 * N - 1;
			a[N+2] = 2 * N - 2;
			b[2 * N - 2] = b[2 * N - 1] = 1;
		} else if(x > N){
			a[N+1] = 2 * N - 1;
			b[2 * N - 1] = 1;
			a[N-1] = 1;
			a[N+2] = 2;
			b[2] = b[1] = 1;
		}
		int y = 1;
		repp(i,1,2*N){
			if(a[i] > 0) continue;
			while(b[y]) ++y;
			a[i] = y;
			++y;
		}
		repp(i,1,2*N){
			printf("%d\n" , a[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 2176
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

while True:
    S = raw_input()
    if S == '0':
        break
    m = [1] + [0 for i in range(10)]
    diff = ans = 0
    even = 1
    S = reversed(S)
    for c in S:
        num = int(c)
        diff = (diff + num * even) % 11
        if num != 0:
            ans += m[diff]
        m[diff] += 1
        even *= -1
    print ans


Measured memory_bytes: 5056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    string S[3]; cin >> S[0] >> S[1] >> S[2];
    int i = 0;
    while(1){
        if(S[i].size() == 0){
            cout << (char) ('A' + i) << endl;
            return 0;
        }
        int before_i = i;
        if(S[i][0] == 'b') i = 1;
        else if(S[i][0] == 'c') i = 2;
        else i = 0;
        S[before_i] = S[before_i].substr(1);
    }
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
a = [1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]
x, y = MAP()
if a[x - 1] == a[y - 1]:
    print("Yes")
else:
    print("No")


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

int main() {
    int n, a, b;
    int x;

    cin >> n >> a >> b;

    // プラン1での駐車料金
    x = n * a;
    
    if (x > b) {
        cout << b << endl;
    }
    else {
        cout << x << endl;
    }
}

Measured memory_bytes: 3604
<?php
$s = trim(fgets(STDIN));
$l = strlen($s);
$head = $l;
$tail = 0;

for($i = 0; $i < $l; $i++) {
    $c = $s[$i];
    if ($head == $l && $c == 'A') {
        $head = $i;
    }
    if ($c == 'Z') {
        $tail = $i;
    }
}

$max = $tail - $head + 1;

echo "$max\n";

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,ans=0;cin>>n;
  rep(i,n) {cin>>a;if(i%2==0&&a%2==1) ans++;}
  print(ans);
  return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, X;
	cin >> N >> X;
	int m[N];
	rep(i, N) cin >> m[i];
	sort(m, m + N);
	int ans = N;
	rep(i, N) X -= m[i];
	cout << ans + X / m[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
bool is_square(int x) {
	int ok = 0, ng = x + 1;
	while (ng - ok > 1) {
		int mid = (ok + ng) / 2;
		if (mid * mid <= x) ok = mid;
		else ng = mid;
	}
	return ok * ok == x;
}
int main() { // 問題文はしっかり読め!!!
	int n, d;
	cin >> n >> d;
	VV p(n, V(d));
	rep(i, n) {
		rep(j, d) {
			cin >> p[i][j];
		}
	}
	int ans = 0;
	rep(i, n) REP(j, i + 1, n) {
		int dist = 0;
		rep(k, d) {
			dist += pow(abs(p[i][k] - p[j][k]), 2);
		}
		ans += is_square(dist);
	}
	cout << ans << endl;
	return 0;
}

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

void solve(const vector<vector<int>>& grafo, vector<int>& resp, int u) {
	// vert, dist
	queue<pair<int,int>> q;
	q.push(make_pair(u, 0));
	vector <int> vis(grafo.size(), false);
	vis[u] = true;

	while(!q.empty()) {
		auto x = q.front();
		q.pop();

		u = x.first;
		int dist = x.second;

		for(auto v: grafo[u]) {
			if(!vis[v]) {
				vis[v] = true;
				resp[dist+1]++;
				q.push(make_pair(v, dist+1));
			}
		}
	}
}

int main() {
	int n,x,y;
	scanf("%d %d %d", &n, &x, &y);
	x--; y--;

	vector<vector<int>> grafo(n);
	for(int i = 0; i < n-1; i++) {
		grafo[i].push_back(i+1);
		grafo[i+1].push_back(i);
	}
	grafo[x].push_back(y);
	grafo[y].push_back(x);
	
	vector<int> resp(n, 0);
	for(int i = 0; i < n; i++) {
		solve(grafo, resp, i);
	}

	for(int i = 1; i < resp.size(); i++) {
		printf("%d\n",resp[i]/2 );
	}

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define PI 3.141592653589793



int main(){
  int N; cin >> N; ll a[N]; int pla = 0;
  rep(i, N){
    cin >> a[i]; if(a[i]>=0) pla++;
  }
  if(pla==0) pla=1;
  if(pla==N) pla=N-1;
  sort(a, a+N, greater<>());
  ll ans = 0;
  rep(i, pla){
    ans+=a[i];
  }
  for(int i=pla; i<N; i++){
    ans-=a[i];
  }
  cout << ans << endl;
  ll x = a[N-1];
  rep(i, pla-1){
    cout << x << " " << a[i] << endl;
    x-=a[i];
  }
  ll xx = a[pla-1];
  rep(i, N-pla-1){
    cout << xx << " " << a[pla+i] << endl;
    xx-=a[pla+i];
  }
  cout << xx << " " << x << endl;
}


Measured memory_bytes: 2688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        int a = 0;
        for (int i=0;i<t;i++)a=Math.max(sc.nextInt(),a);
        System.out.println(Math.max(0,a*2-k-1));
    }
}


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

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int> cnt(m);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			a--;
			cnt[a]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if(cnt[i] == n) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;


int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool t=false,w=false;
    for(int i=0; ; i++){
        if(c<=0){
            t=true;
            break;
        }
         if(a<=0){
            w=true;
            break;
        }
        if(i%2==0){
            c-=b;


        }
        else
            a-=d;
    }
    if(t==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int64_t a;
    string b, b1;
    cin >> a >> b;

    rep(i, b.length())
    {
        if (b[i] != '.')
        {
            b1 += b[i];
        }
    }
    ll c = stoi(b1);

    // cout << b << "," << c << endl;
    cout << (a * c) / 100 << endl;

    return 0;
}


Measured memory_bytes: 3628
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;

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

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

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

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

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

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

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

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

const INF: i64 = 1 << 60;

fn main() {
    input!{
        N: usize,
        A: [usize; N],
    }
    for i in A {
        if i%2 == 0 {
            if i%3 != 0 && i%5 != 0 {
                println!("DENIED");
                return;
            }
        }
    }
    println!("APPROVED");
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      int d = s.charAt(i) - 'A';
      d = (d + n) % 26;
      String c = String.valueOf((char)('A' + d));
      ans += c;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 146900
class PriorityQueue

  def initialize(heap=[])
    @size = heap.size
    @heap = heap.sort
  end

  # log( log n )
  def push x
    i = @size
    @size += 1
    while i > 0
      par = ( i - 1 ) / 2
      break if @heap[par] <= x
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  # log( log n )
  # return nil if @size == 0
  def pop

    ret = @heap[0]
    x = @heap[@size-=1]
    # @heap.delete_at(-1)

    i = 0
    while (child = i * 2 + 1) < @size
      child_1 = i * 2 + 2
      child = child_1 if child_1 < @size && @heap[child_1] < @heap[child]
      break if @heap[child] >= x
      @heap[i] = @heap[child]
      i = child
    end

    @heap[i] = x
    @heap.delete_at(-1)
    ret
  end

  def size
    @heap.size
  end

  def top
    @heap[0]
  end

  def any?
    @size > 0
  end

  def empty?
    @size == 0
  end

  def all
    @heap
  end

  def first
    @heap[0]
  end

  def second
    @size < 3 ? @heap[1] : [@heap[1], @heap[2]].min
  end

  def third
    @size < 3 ? nil : [@heap[1], @heap[2]].max
  end
  
  def sum
    @heap.reduce(0){|s,t| s+t }
  end
end

class Array

  include Comparable

  def to_pq
    PriorityQueue.new(self)
  end
end

n, m = gets.to_s.split.map{|t|  t.to_i }
a    = gets.to_s.split.map{|t| -t.to_i }
# 大きい順に見たいが、PriorityQueueが小さいのが優先なので、マイナスをつけていく。

q = PriorityQueue.new(a)

m.times do
  price_x = -q.pop
  # p price_x
  q.push( -(price_x / 2) )
end
# p q.all
puts -q.sum





Measured memory_bytes: 10128
n = int(input())
heap_keys = list(map(int, input().split()))
heap = []
for i,x in enumerate(heap_keys):
    node = i+1
    key = x
    parent_key = heap_keys[int(node/2)-1] if i > 0 else None
    left_key = heap_keys[2*node-1] if 2*node-1 <len(heap_keys) else None
    right_key = heap_keys[2*node] if 2*node <len(heap_keys) else None
    heap.append({"node":node, "key":x, "parent_key":parent_key, "left_key":left_key, "right_key":right_key})

for h in heap:
    out_str = "node %s: key = %s, " % (h["node"],h["key"])
    if h["parent_key"]:out_str += "parent key = %s, " % h["parent_key"]
    if h["left_key"]:out_str += "left key = %s, " % h["left_key"]
    if h["right_key"]:out_str += "right key = %s, " % h["right_key"]
    print(out_str)

Measured memory_bytes: 7704
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    lint a=0,b=0;
    for(char c:s)(c=='0'?a:b)++;
    std::cout<<std::min(a,b)*2<<'\n';
}


Measured memory_bytes: 512
from collections import Counter
N = int(input())
S = [input() for i in range(N)]

maxkey = None
result = []
for (val, key) in Counter(S).most_common():
  if maxkey == None:
    maxkey = key
    result.append(val)
  else:
    if maxkey == key:
      result.append(val)
    else:
      break

for r in sorted(result):
  print(r)

Measured memory_bytes: 45032
#include <iostream>
#include <algorithm>

int n,k;

int x;

int main() {

    std::cin>>n>>k;

    int sum=0;

    for(int i=0;i<n;++i){
        std::cin>>x;
        sum+=std::min(x,std::abs(x-k))*2;
    }
    
    std::cout<<sum<<std::endl;

    return 0;
}

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int l=min(a+b,a+c);
    l=min(l,b+c);
    cout<<l<<endl;
}


Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    double h, w, x, y;
    cin >> h >> w >> x >> y;
    double ret = h * w / 2;
    bool has = (2 * x == h && 2 * y == w);
    cout << setprecision(10) << ret << " " << has << endl;
    return 0;
}

Measured memory_bytes: 3792
def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))

    left = 0
    right = max(A)

    while abs(right-left)>1:
        cent = (right+left)//2
        
        ct = 0
        for a in A:
            ct+=(a-0.1)//cent
        
        if ct <= k:
            right=cent
        else:
            left=cent
    
    print(right)
main()

Measured memory_bytes: 30740
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}

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

q1,q2,q3=0,0,0

for i in range(n):
    if p[i]<=a:
        q1+=1
    elif p[i]<=b:
        q2+=1
    else:
        q3+=1

print(min([q1,q2,q3]))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int H, W, K;
int sx, sy, ex, ey;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(void){
    cin >> H >> W >> K;
    vector<vector<char>> c(H, vector<char>(W));
    vector<vector<int>> dp(H, vector<int>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dp[i][j] = INT_MAX;
        }
    }
    cin >> sx >> sy >> ex >> ey;
    sx--;
    sy--;
    ex--;
    ey--;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> c[i][j];
        }
    }
    queue<pair<int, int>> q;
    q.push({sx, sy});
    dp[sx][sy] = 0;
    while(!q.empty()){
        pair<int,int> pi = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            for(int j = 1; j <= K; j++){
                int nx = pi.first+j*dx[i];
                int ny = pi.second+j*dy[i];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if(c[nx][ny] == '@' || dp[nx][ny] <= dp[pi.first][pi.second]) break;
                if(dp[nx][ny] > dp[pi.first][pi.second]+1){
                    q.push({nx, ny});
                    dp[nx][ny] = dp[pi.first][pi.second]+1;
                }
            }
        }
    }
    if(dp[ex][ey] == INT_MAX) cout << -1 << endl;
    else cout << dp[ex][ey] << endl;

    return 0;
}


Measured memory_bytes: 11828
#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  if(x%y==0) return y;
  return gcd(y,x%y);
}

int main() {
 int a,b,c;
  cin>>a>>b>>c;
  int g=gcd(a,b);
  if(c%g==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

const int mod = 998244353;

template <class T>
inline int remainder(const T & x)
{
	if (x < 0)
		return x + mod;
	else if (x < mod)
		return x;
	else
		return x - mod;
}

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

	int N, K;
	cin >> K >> N;

	vector<vector<int> > C(N + K);
	for (int n = 0; n < C.size(); n++)
	{
		C[n].resize(n + 1);
		C[n][0] = C[n][n] = 1;
		for (int k = 1; k < n; k++)
			C[n][k] = remainder(C[n - 1][k - 1] + C[n - 1][k]);
	}
	auto Cb = [&](const int & n, const int & k)
	{
		if (k == 0)
			return 1;
		else if (n == 0)
			return 0;
		else
			return C[n + k - 1][k];
	};

	vector<vector<int> > fv(3, vector<int>(N + 1, 0));
	vector<vector<int> > sv(3, vector<int>(N + 2, 0));

	fv[2][0] = 1;
	partial_sum(fv[2].begin(), fv[2].end(), sv[2].begin());
	vector<int> ansv(K * 2 - 1, 0);
	for (int k = 0; k < K; k++)
	{
		int cur = k % 3, prv = ((k - 2) % 3 + 3) % 3;
		if (k == 0)
			fv[cur][0] = fv[cur][1] = 1;
		else
		{
			fv[cur][0] = 1;
			for (int i = 1; i <= N; i++)
				fv[cur][i] = remainder(remainder(sv[prv][i - 1] << 1) + fv[prv][i]);
		}
		// cerr << "fv[" << k << "] = {";
		// for (int i = 0; i < fv[cur].size(); i++)
		// {
		// 	if (i > 0)
		// 		cerr << ", ";
		// 	cerr << fv[cur][i];
		// }
		// cerr << "}" << endl;
		for (int i = 0, x = 0; i <= N; i++)
			sv[cur][i] = x = remainder(x + fv[cur][i]);
		int ans = 0;
		for (int i = N; i >= 0; i--)
			ans = remainder(ans + (long long)fv[cur][i] * Cb(K - k - 1, N - i) % mod);
		ansv[k] = ansv[K * 2 - 2 - k] = ans;
	}

	for (const auto & ans : ansv)
		cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 35140
#include <iostream>
#include <cstring>
#include <cstdio>

#define R register
#define Maxn 100010

using namespace std;

typedef long long ll;
int n , g , N , sum;
int p[Maxn] , c[Maxn];
ll f[Maxn];

int main() {
	
	scanf("%d%d",&n,&g);
	for(R int i=1; i<=n; i++) {
		scanf("%d%d",&p[i],&c[i]);
		sum += p[i];
	}
	
	for(R int i=1; i<=n; i++) {
		for(R int j=sum; j>=0; j--) {
			for(R int k=1; k<=p[i]; k++) {
				if(j-k < 0)	break;
				if(k < p[i])	f[j] = max(f[j],f[j-k]+ll(100*i*k));
				else	f[j] = max(f[j],f[j-k]+ll(100*i*k)+(ll)c[i]);
			}
		}
	}
	
	for(R int i=1; i<=sum; i++)
		if(f[i] >= g)
			return printf("%d\n",i) , 0;
	
	return 0;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    if (a > b) {
      System.out.println(a - 1);
    } else {
      System.out.println(a);
    }
  }
}

Measured memory_bytes: 21332