akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	std::string S;
	std::cin >> S;

	if (S == "AAA" || S == "BBB")
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main(){
  int N,X;
  int L[101];
  int D[101];
  int ans;
  cin >> N >> X;

  for(int i = 1;i <= N+1;i++){
    cin >> L[i];
  }
  
  for(int i = 1;i <= N+1;i++){
    if(i == 1){
      D[i] = 0;
    }else{
      D[i] = D[i-1] + L[i-1];
      if(D[i] > X){
        ans = i-1;
        break;
      }else{
        ans = N+1;
      }
    }
    
  }
  
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string str;

int cnt[3];

void solve() {
	cin >> str;
	N = sz(str);
	rep(i, 0, N) {
		cnt[str[i] - 'a']++;
	}
	int mv = inf;
	rep(i, 0, 3) MIN(mv, cnt[i]);
	rep(i, 0, 3) {
		if(cnt[i] - mv >= 2) {
			cout << "NO\n"; return;
		}
	}
	cout << "YES\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
long long w[3];
int main(){
    int i;
    for(i=0;i<3;i++)scanf("%lld",&w[i]);
    sort(w,w+3);
    if(w[0]%2==0||w[1]%2==0||w[2]%2==0){
        printf("0\n");
    }
    else printf("%lld\n",w[0]*w[1]);
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    
    void solve(){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int[] kura = new int[n];
        int[] shiro = new int[n];
        int[] sen = new int[n];
        for(int i=0; i<n; i++){
            kura[i] = sc.nextInt();
            shiro[i] = sc.nextInt();
            sen[i] = sc.nextInt();
        }
        
        double[][] dp = new double[1<<n][n];
        int[][] before = new int[1<<n][n];
        int[][] weight = new int[1<<n][n];
        for(int i=0; i<1<<n; i++){
            Arrays.fill(dp[i], -1.0);
            Arrays.fill(before[i], -1);
            Arrays.fill(weight[i], -1);
        }
        dp[0][0] = 0;
        for(int bit=0; bit<1<<n; bit++){
            for(int i=0; i<n; i++){
                if(dp[bit][i]>-1){
                    for(int j=0; j<n; j++){
                        if((bit&(1<<j))>0) continue;
                        double nn = dp[bit][i] + Math.abs(shiro[i] - shiro[j]) / (2000.0/(double)(70+weight[bit][i]));
                        int newBit = bit^(1<<j);
                        if(dp[newBit][j]<=0 || dp[newBit][j]>nn){
                            dp[newBit][j] = nn;
                            before[newBit][j] = i;
                            weight[newBit][j] = weight[bit][i] + sen[j] * 20;
                        }
                    }
                }
            }
        }

        int idx = 0;
        double min = Double.MAX_VALUE;
        for(int i=0; i<n; i++){
            if(dp[(1<<n)-1][i]>-1 && dp[(1<<n)-1][i]<min){
                min = dp[(1<<n)-1][i];
                idx = i;
            }
        }
        
        ArrayList<Integer> list = new ArrayList<Integer>();   
        list.add(new Integer(kura[idx]));
        int b = (1<<n)-1;
        while(before[b][idx]!=-1){
            list.add(new Integer(kura[before[b][idx]]));
            int newbit = b ^ (1<<idx);
            idx = before[b][idx];
            b = newbit;
        }
        
        for(int i=list.size()-2; i>0; i--) System.out.print(list.get(i)+" ");
        System.out.println(list.get(0));
    }

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

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

int main(){
	int tuki, hi, k = 0;
	int nissuu[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string youbi[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	string out[100];
	while(cin >> tuki >> hi){
		if(tuki == 0){
			break;
		}
		int a = 0;
		for(int i = 0; i < tuki-1; i++){
			a = a+nissuu[i];
		}
		a = (a+hi)%7;
		out[k] = youbi[a];
		k++;
	}
	for(int i = 0; i < k; i++){
		cout << out[i] << endl;
	}
}

Measured memory_bytes: 1200
nm = input()
nm = nm.split()
n = int(nm[0])
m = int(nm[1])
nums = input()
nums = nums.split()
nums2 = []
for i in nums:
  nums2.append(int(i))
nums2.sort()
nums3 = []
i = 1
while i<len(nums2):
  nums3.append(nums2[i]-nums2[i-1])
  i+=1
nums3.sort()
nums3 = nums3[:len(nums3)-n+1]
if(n>=m):
  print(0)
else:
  print(sum(nums3))

Measured memory_bytes: 57256
object Main extends App {

  import scala.io.StdIn._
  val n = readLine.trim.toInt
  println(
    countMaxLength(readLine.trim.split(' ').map(_.toInt).toList) + 1
  )
  def countMaxLength(cell: List[Int], count: Int = 0, max: Int = 0): Int = {
    cell match{
      case Nil ⇒ if (count > max) count else max
      case 1::t ⇒ countMaxLength(t, count + 1, max)
      case 0::t ⇒ if (count > max) countMaxLength(t, 0, count) else countMaxLength(t, 0, max)
      case _ ⇒ throw new Exception
    }
  }
}



Measured memory_bytes: 44108
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	string s;
	cin >> s;

	string s1 = s.substr(0, 2);
	string s2 = s.substr(2, 4);

	int a = atoi(s1.c_str());
	int b = atoi(s2.c_str());

	if (a < 13 && a > 0 && b < 13 && b > 0) cout << "AMBIGUOUS" << endl;
	else if (a < 13 && a>0) cout << "MMYY" << endl;
	else if (b < 13 && b>0) cout << "YYMM" << endl;
	else cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int i,j,k,n,m,a[310][310],b[310],d[310];
	bool c[310];
	cin >> n >> m;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin >> a[i][j];
		}
	}
	
	for(i=1;i<=n;i++){
		int cnt = 0;
		for(j=1;j<=m;j++){
			b[j] = 0;
			c[j] = true;
		}
		for(j=0;j<n;j++){
			b[a[j][0]]++;
			d[j] = 0;
		}
		while(cnt<m){
			for(j=0;j<n;j++){
				for(k=d[j];k<m;k++){
					if(c[a[j][k]]){
						if(k!=d[j]){
							b[a[j][k]]++;
							d[j] = k;
							break;
						}else{
							break;
						}
					}
				}
			}
			int mx = 0;
			for(j=1;j<=m;j++){
				mx = max(mx,b[j]);
				if(b[j]>i){
					c[j] = false;
					cnt++;
					b[j] = 0;
				}
			}
			if(mx<=i){
				cout << i << endl;
				return 0;
			}
		}
	}
}
		

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

int main(){
	int a,b;
	char op;
	
	while(cin>>a>>op>>b)
	{
		if(op=='?')
		{
			break;
		}
		if(op=='+')
		{
			cout<<a+b<<endl;
		}
		else if(op=='-')
		{
			cout<<a-b<<endl;
		}
		else if(op=='*')
		{
			cout<<a*b<<endl;
		}
		else if(op=='/')
		{
			cout<<a/b<<endl;
		}
	}
	
	return 0;
}



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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int num = 0;
    while(n >= k){
        n = n/k;
        num++;
    }
    cout << num+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(200200);
    REP(i,0,n){
        int x;
        cin >> x;
        a[x]++;
    }
    sort(a.begin(),a.end(),greater<int>());
    long cnt = 0;
    REP(i,k,n) cnt+=a[i];
    cout << cnt << endl;
    return 0;
}

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

int w, h, k;

int is_edge(int ii, int jj) {
  return ii == 0 || jj == 0 || ii == h-1 || jj == w-1;
}

int min(int ii, int jj) {
  if (ii < jj){
    return ii;
  } else {
    return jj;
  }
}

int main() {
  char a[800][800];
  int b[640000][2];
  int i, j;
  int x, y, xy;
  int si, sj;
  scanf("%d %d %d", &h, &w, &k);
  for (i = 0; i < h; i = i+1) {
    scanf("%s", a[i]);
  }
  for (i = 0; i < h; i = i+1) {
    for (j = 0; j < w; j = j+1) {
      if (a[i][j] == 'S') {
	si = i;
	sj = j;
      }
    }
  }

  b[0][0] = si;
  b[0][1] = sj;
  int l = 0;
  int r = 1;
  
  for (i = 0; i < k; i = i+1) {
    if (l == r) {
      break;
    }
    /*d is the number of points to be evaluated*/
    /*l is the number of points evaluated*/
    /*r is the number of points in the list b*/
    int d = 0;
    for (j = l; j < r; j = j+1) {
      int x = b[j][0];
      int y = b[j][1];
      if (!is_edge(x,y)) {
	/*search points around (x,y)*/
	if (a[x][y+1] == '.') {
	  b[r+d][0] = x;
	  b[r+d][1] = y+1;
	  a[x][y+1] = 'f';
	  d = d+1;
	}
	if (a[x][y-1] == '.') {
	  b[r+d][0] = x;
	  b[r+d][1] = y-1;
	  a[x][y-1] = 'f';
	  d = d+1;
	}
	if (a[x+1][y] == '.') {
	  b[r+d][0] = x+1;
	  b[r+d][1] = y;
	  a[x+1][y] = 'f';
	  d = d+1;
	}
	if (a[x-1][y] == '.') {
	  b[r+d][0] = x-1;
	  b[r+d][1] = y;
	  a[x-1][y] = 'f';
	  d = d+1;
	}
      }
    }
    l = r;
    r = r+d;
  }
  /*
  for (i = 0; i < r; i = i+1) {
    printf("%d %d\n", b[i][0], b[i][1]);
  }
  */
  
  
  /*    for (i = 0; i < h; i = i+1) {
    for (j = 0; j < w; j = j+1) {
      printf("%d", b[i][j]);
    }
    printf("\n");
    }  */
  

  int ans = 800;

  for (i = 0; i < r; i = i+1) {
    x = ceil(((double)min(b[i][0], h-b[i][0]-1))/k) + 1;
    y = ceil(((double)min(b[i][1], w-b[i][1]-1))/k) + 1;
    xy = min(x, y);
    ans = min(xy, ans);
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;
import java.util.Arrays;
import java.lang.Math;
import java.util.ArrayList;

  
public class Main {
	static class Key {
        public int cost;
        public int state;
      }
  
  	void run() {
     
    }

    public static void main(String[] args) {
     // new Main().run();
       
      Scanner scanner = new Scanner(System.in);
      int n = scanner.nextInt();
      int m = scanner.nextInt();
      int[] results = new int[1 << n];
      Arrays.fill(results, 0x35f5e100);
      
      ArrayList<Key> keys = new ArrayList(m);
      //Key[] keys = new Key[m];
      for (int i = 0; i < m; i++) {
        Key k = new Key();
        k.cost= scanner.nextInt();
        int num = scanner.nextInt();
        int sum = 0;
        while (num > 0) {
          	sum |= 1 << (scanner.nextInt() - 1);
        	num--;
        }
        k.state = sum;
        results[sum] = k.cost;
        keys.add(k);
      }
      
      results[0] = 0;
	  for (int i = 0; i < results.length; i++) {
        for (int j = 0; j < m; j++) {
          results[i | keys.get(j).state] = 
            Math.min(results[i | keys.get(j).state], results[i] + keys.get(j).cost);
        }
        //System.out.println(results[i]);
      }
      
      if (results[results.length - 1] == 0x35f5e100)
        System.out.println("-1");
      else
        System.out.println(results[results.length - 1]);
    }
  
}


Measured memory_bytes: 31900
#include <iostream>

int main(int argc, char const* argv[])
{
  int n;
  std::string s, t;

  std::cin >> n;
  std::cin >> s >> t;

  // std::cout << n << std::endl;
  // std::cout << s << ' ' << t << std::endl;

  for (int i = 0; i < n; i++) {
    std::cout << s[i] << t[i];
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : December 02 2019 23:15:18 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n;
    cin >> n;
    vi cnt(26);
    fori(i,n){
        string s;
        cin >> s;
        vi cnt1(26);
        trav(c,s){
            cnt1[c-'a']++;
        }
        if(i==0) cnt=cnt1;
        else {
            fori(i,26){
                cnt[i] = min(cnt[i],cnt1[i]);
            }
        }
    }
    fori(i,26){
        fori(_,cnt[i]){
            cout << char('a'+i);
        }
    }
    cout << endl;

    time_taken();
    return 0;
}

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

int main() {

    int n;

    cin >> n;

    if(n == 2) {
        cout << 2 << endl;
        return 0;
    }

    if(n % 2 == 0)
        n++;
    

    while(1) {

        bool isPrime = true;

        for(int i = 3; i * i <= n; i+=2) {
            if(n % i == 0) {
                isPrime = false;
                break;
            }

        }

        if(isPrime)
            break;

        n += 2;

    }

    cout << n << endl;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, e, f, g, h;
	int hit, blow;
	while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
		hit = 0;
		blow = 0;
		if      (a == e){
			//cout << "11" << endl;
			hit += 1;
		}
		else if (a == f){
			//cout << "12" << endl;
			blow += 1;
		}
		else if (a == g) {
			//cout << "13" << endl;
			blow += 1;
		}
		else if (a == h) {
			//cout << "14" << endl;
			blow += 1;
		}
		if (b == e) {
			//cout << "21" << endl;
			blow += 1;
		}
		else if (b == f) {
			//cout << "22" << endl;
			hit += 1;
		}
		else if (b == g) {
			//cout << "23" << endl;
			blow += 1;
		}
		else if (b == h) {
			//cout << "24" << endl;
			blow += 1;
		}
		if (c == e) {
			//cout << "31" << endl;
			blow += 1;
		}
		else if (c == f) {
			//cout << "32" << endl;
			blow += 1;
		}
		else if (c == g) {
		//	cout << "33" << endl;
			hit += 1;
		}
		else if (c == h) {
	//		cout << "34" << endl;
			blow += 1;
		}
		if (d == e) {
	//		cout << "41" << endl;
			blow += 1;
		}
		else if (d == f) {
	//		cout << "42" << endl;
			blow += 1;
		}
		else if (d == g) {
	//		cout << "43" << endl;
			blow += 1;
		}
		else if (d == h) {
	//		cout << "44" << endl;
			hit += 1;
		}
		cout << hit <<" "<< blow << endl;
	}
}

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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin>>d.at(i);
  }
  sort(d.begin(),d.end());
  cout << fixed << setprecision(6);
  double ans = d.at(0);
  for(int i=1; i<N; i++){
    ans += d.at(i);
    ans /=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
if n == 0:
  print(0)
  exit()
ans = ""
while n != 0:
  if n%-2 < 0:
    r = n%-2+2
    n = n//-2+1
  else:
    r = n%-2
    n = n//-2
  ans += str(r)
print(int(ans[::-1]))

Measured memory_bytes: 3060
import Control.Applicative
import Data.List
strToInteger s = (read :: String -> Integer) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, x] <- map strToInteger . words <$> getLine
    -- スペース区切り整数の入力
    as <- map strToInteger . words <$> getLine
    let as' = if x < head as then x:(drop 1 as) else as
    -- 出力
    putStrLn . show $ ((sum as) - (sum $ operate as' x))

operate :: [Integer] -> Integer -> [Integer]
operate (a1:[]) x = [a1]
operate (a1:a2:bs) x
    | a1 + a2 <= x = (:) a1 $ operate (a2:bs) x
    | otherwise    = (:) a1 $ operate (a2':bs) x where a2' = x - a1


Measured memory_bytes: 52604
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int H, W, K;
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> H >> W >> K;
  vec<int> dp0(W, 0);
  vec<int> dp1(W, 0);
  vec<int> fact(W + 1);
  fact[0] = 1, fact[1] = 1;
  FORS(i, 2, W) fact[i] = fact[i - 1] + fact[i - 2];
  dp0[0] = 1;
  REP(i, H) {
    REP(j, W) {
      if (W >= 2 && j >= 1) {
        dp1[j - 1] += dp0[j] * fact[j - 1] * fact[W - 2 - (j - 1)];
        dp1[j - 1] %= MOD;
      }
      dp1[j] += dp0[j] * fact[j] * fact[W - 1 - j];
      dp1[j] %= MOD;
      if (W >= 2 && j < W - 1) {
        dp1[j + 1] += dp0[j] * fact[j] * fact[W - 2 - j];
        dp1[j + 1] %= MOD;
      }
    }
    // DEBUG(i);
    //   PRINTALL(dp0);
    //  PRINTALL(dp1);
    dp0 = dp1;
    fill(ALL(dp1), 0);
    // PRINTALL(dp0);
    // PRINTALL(dp1);
    // dp1 = dp0; }
  }
  print(dp0[K - 1]);
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<0.5<<endl;
    }
    else{
        int nn=n/2;
        cout<<(double)(nn+1)/(double)(n)<<endl;    
    }
    return 0;
}

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

int n, q;

int BinarySearch(int data[], int samp[]) {
	int left, right, mid, cnt = 0;
	for (int i = 0;i < q;i++) {
		left = 0;
		right = n;
		while (left < right) {
			mid = (right + left) / 2;
			if (samp[i] == data[mid]) {
				cnt++;
				break;
			}
			else if (samp[i] < data[mid]) right = mid;
			else left = mid + 1;
		}
		
	}

	return cnt;
}

int main() {
	int S[100005], T[50004];
	cin >> n;
	for (int i = 0;i <= n - 1;i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0;i <= q - 1;i++) {
		cin >> T[i];
	}

	

	cout << BinarySearch(S, T) << endl;
	return 0;
}

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

#define MAX 100000
#define NIL -1

struct Node{
    int parent;
    int left;
    int right;
};

Node T[MAX];

int getDepth(int u)
{
    int d=0;
    while (T[u].parent != NIL){
        u = T[u].parent;
        ++d;
    }
    return d;
}

int D[MAX];

int setDepth(int u, int p)
{
    D[u] = p;
    if( T[u].right != NIL ){
        setDepth(T[u].right, p);
    }
    if( T[u].left != NIL ){
        setDepth(T[u].left, p+1);
    }

}

void printChildren(int u){

    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";
    if( T[u].parent == NIL)
        cout << "root, ";
    else if(T[u].left ==NIL )
        cout << "leaf, ";
    else
        cout << "internal node, ";

    cout << "[";

    for( int i=0, c = T[u].left; c!=NIL; i++ ,c = T[c].right){
        if(i)
            cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n ; ++i){
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }

    for(int i=0; i<n; ++i){
        int v, d;
        cin >> v >> d;
        int l;
        for(int j=0; j<d; ++j){
            int c;
            cin >>c;
            if(j==0)
                T[v].left = c;
            else
                T[l].right = c;
            l =c;
            T[c].parent = v;
        }
    }

    int r;
    for(int i=0; i<n; i++){
        if( T[i].parent == NIL)
            r=i;
    }

    setDepth(r,0);

    for(int i=0; i<n; ++i)
        printChildren(i);

}



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

int G[205][205];

int gcd(int a, int b){
  if(G[a][b]!=-1)return G[a][b];
  if(b==0)return G[a][b] = a;
  return G[a][b] = gcd(b, a%b);
}

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


  memset(G, -1, sizeof(G));

  int k;cin>>k;

  long long ans = 0;
  for(int a=1; a<=k; a++)
    for(int b=1; b<=k; b++)
      for(int c=1; c<=k; c++){
        ans += gcd(gcd(a, b), c);
      }

    cout<<ans<<"\n";

  return 0;
}


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

using namespace std;

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

    int x;
    x = (a + b) * 10 / 2;

    if (x % 10 == 0) {
        cout << x / 10 << endl;
    } else {
        cout << x / 10 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
H, W = map(int,input().split())

a = []

for i in range(H):

    newa = input()
    newa_l = list(newa)
    a.append(newa_l)

bigbul = True
while bigbul:

    bigbul = False
    acp = a.copy()
    
    for i in range(H):
    
        bul = True
        for j in range(W):

            if a[i][j] != ".":
                bul = False
                break

        if bul:
            del acp[i]
            a = acp.copy()
            H -= 1
            bigbul = True
            break

bigbul = True
while bigbul:

    bigbul = False
    acp = a.copy()

    #print("W", W)

    for j in range(W):

        bul = True

        for i in range(H):

            if a[i][j] != ".":
                bul = False
                break


        if bul:

            for k in acp:

                del k[j]
                #print ("nowk")

                #for i in acp:
                    #ans = "".join(i)
                    #print (ans)

            a = acp.copy()
            W -= 1
            bigbul = True
            break

for i in a:
    ans = "".join(i)
    print (ans)

    


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

using namespace std;

using ll = long long;

const ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector< vector<ll> > dp(n + 1, vector<ll>(5, INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        dp[i+1][0] = dp[i][0] + a[i];
        dp[i+1][1] = *min_element(dp[i].begin(), dp[i].begin() + 2) + (a[i] == 0 ? 2 : a[i] % 2);
        dp[i+1][2] = *min_element(dp[i].begin(), dp[i].begin() + 3) + 1 - a[i] % 2;
        dp[i+1][3] = *min_element(dp[i].begin(), dp[i].begin() + 4) + (a[i] == 0 ? 2 : a[i] % 2);
        dp[i+1][4] = *min_element(dp[i].begin(), dp[i].begin() + 5) + a[i];
    }
    cout << *min_element(dp[n].begin(), dp[n].end()) << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;

int n, m, a, b, p1, p2;
vector<int> v[100002];
int bio[100002][5];
queue< pair<int, int> > q;

void bfs() {
	
	while (!q.empty()) {
		int x = q.front().X;
		int y = q.front().Y;
		q.pop();
		for (int i = 0; i < v[x].size(); i ++) {
			int sus = v[x][i];
			if (bio[sus][(y+1) % 3] == -1) {
				bio[sus][(y+1) % 3] = bio[x][y]+1;
				q.push({sus, (y+1)%3});
			}
		}
	}

}

int main () {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a].push_back(b);
	}
	
	cin >> p1 >> p2;
	memset(bio, -1, sizeof bio);
	bio[p1][0] = 0;
	q.push({p1, 0});
	bfs();
	if (bio[p2][0] == -1) cout << -1;
	else cout << bio[p2][0]/3;

	return 0;
}

Measured memory_bytes: 7680
#include <stdio.h>
int main ()
{
    int i,j,count=0;
    char S[4];
    scanf ("%s", S);
    if (S[0]==S[1]) {
        count++;
    }
    if (S[0]==S[2]) {
        count++;
    }
    if (S[0]==S[3]) {
        count++;
    }
    if (S[1]==S[2]) {
        count++;
    }
    if (S[1]==S[3]) {
        count++;
    }
    if (S[2]==S[3]) {
        count++;
    }

    if (count==2) {
        printf ("Yes\n");
    }
    else {
        printf ("No\n");
    }




    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main(void) {

    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=INF;
    int l=0,r=0;
    r=stringcount(s,'.');
    rep(i,n){
        // cout<<i<<" "<<l<<" "<<r<<endl;
        chmin(ans,r+l);
        if(s[i]=='.'){
            r--;
        } else {
            l++;
        }
    }
    chmin(ans,stringcount(s,'#'));
    fin(ans);

}

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

int main(void) {
	char a[101];
	int ans = 0;
	scanf("%s", a);
	for (int i = 0; i < strlen(a) / 2; ++i) {
		if (a[i] != a[strlen(a) - i - 1]) {
			++ans;
		}
	}
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n;
long long int ryuka(int i,long long int l1,long long int l2);
int main(){
  cin >> n;
  cout << (n!=1 ? ryuka(2,1,2):1) << endl;
}

long long int ryuka(int i,long long int l1,long long int l2){
  if(i>n)return l1;
  ryuka(i+1,l1+l2,l1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  if (n%x == 0)
  {
    cout << n/x*t << endl;
  }else
  {
    cout << (n/x+1)*t << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3584
import math
A,B,H,M = map(int,input().split())
V1 = 30
V2 = 30/60
v = 6
d = abs( (V1*H + V2*M) - v*M)
if d == 0:
  print(abs(A-B))
else:
  print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))

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

int main(){
	int a, b, at, bt;
	
loop:
	if(feof(stdin)) goto end_scope;
	scanf("%d %d\n", &a, &b);		// データセット
	{
		stringstream ss;
		ss << a+b;
		cout << ss.str().length() << endl;
	}
	goto loop;
end_scope:
    return 0;
}

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

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

    int x = 0;
    int ans = X.size();
    for (char ch : X) {
        if (ch == 'S') x++;
        else if (x > 0) {
            x--;
            ans -= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        int A = Integer.valueOf(N.substring(0,1));
        int B = Integer.valueOf(N.substring(1,2));
        int C = Integer.valueOf(N.substring(2,3));
        int D = Integer.valueOf(N.substring(3,4));
        String op[][] = new String[][]{
            {"+", "+", "+"},
            {"+", "+", "-"},
            {"+", "-", "+"},
            {"-", "+", "+"},
            {"+", "-", "-"},
            {"-", "+", "-"},
            {"-", "-", "+"},
            {"-", "-", "-"},
        };
        for(int i = 0; i < op.length; i++){
            int tmp;
            if(op[i][0].equals("+")) {
                tmp = A + B;
            }else {
                tmp = A - B;
            }

            if(op[i][1].equals("+")) {
                tmp = tmp + C;
            }else {
                tmp = tmp - C;
            }

            if(op[i][2].equals("+")) {
                tmp = tmp + D;
            }else {
                tmp = tmp - D;
            }

            if(tmp == 7) {
                System.out.println(A+op[i][0]+B+op[i][1]+C+op[i][2]+D+"=7");
                return;
            }
        }


    }
}

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

int main()
{
    int k,s;
    int ans = 0;

    cin >> k >> s;

    for (int x = 0;x <= k;++x)
        for (int y = 0;y <= k;++y) {
            int z = s - x - y;
            if (z >=0 && z <=k)
                    ++ans;
        }

//    cout << fixed << setprecision(6) << ans << endl;
    cout << ans << endl;

    return(0);
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 n, m; cin >> n >> m;
  vi64 a(n); rep(i, n) cin >> a[i];
  vi64 sums(n + 1, 0);
  rep(i, n) sums[i + 1] = (sums[i] + a[i]) % m;
  unordered_map<i64, i64> mp;
  rep(i, n + 1) mp[sums[i]]++;
  i64 ans = 0;
  for (auto v: mp) {
    ans += v.second * (v.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5260
//https://qiita.com/tanakh/
#[allow(unused_macros)]
macro_rules! input {
	(source = $s:expr, $($r:tt)*) => {
		let mut iter = $s.split_whitespace();
		let mut next = || { iter.next().unwrap() }; 
		input_inner!{next, $($r)*}
	};
	($($r:tt)*) => {

		let stdin = std::io::stdin();
		let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); 
		let mut next = move || -> String{
			bytes
				.by_ref()
				.map(|r|r.unwrap() as char) 
				.skip_while(|c|c.is_whitespace()) 
				.take_while(|c|!c.is_whitespace()) 
				.collect()
			};
	input_inner!{next, $($r)*} 
	};
}

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

	($next:expr, $var:ident : $t:tt $($r:tt)*) => { 
		let $var = read_value!($next, $t); 
		input_inner!{$next $($r)*}
	}; 
}
#[allow(unused_macros)]
macro_rules! read_value { 
	($next:expr, ( $($t:tt),* )) => {
		( $(read_value!($next, $t)),* ) 
	};
	
	($next:expr, [ $t:tt ; $len:expr ]) => {
		(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
	};

	($next:expr, chars) => {
		read_value!($next, String).chars().collect::<Vec<char>>()
	};
	
	($next:expr, bytes) => {
		read_value!($next, String).into_bytes()
	};
	
	($next:expr, usize1) => { 
		read_value!($next, usize) - 1
	};

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

fn main(){
    input!{
        a : i64,
        b : i64,
        c : i64,
        k : i64,
    }
    if k % 2 != 0 {
        println!("{}",b - a);
    } else {
        println!("{}",a - b);
    }
}

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

int main(){
	string s;
	cin >> s;
	map<char, int> cnt;
	for(char c : s) cnt[c]++;

	int odd_num = 0;
	for(auto p : cnt){
		if(p.second%2) odd_num++;
	}
	cout << odd_num/2 << endl;
}



Measured memory_bytes: 3244
#include <iostream>
#include <vector>
 
#define ll long long 
#define repd(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) repd(i, 0, n)
using namespace std;
 
ll GetDigit(ll num){
    return to_string(num).length();
}
 
int main(){
  int n;
  cin >> n;
  unsigned long long ans = 1;
  // bool zero_flag = false;
  bool over_flag = false;
  rep(i, n){
    ll a;
    cin >> a;
    if(a == 0){
      cout << 0 << endl;
      return 0;
    }
    // cout << ans << endl;
    // cout << GetDigit(ans) << endl;
    // cout << GetDigit(a)<< endl;
    // cout << GetDigit(ans) + GetDigit(a) -2 << endl;
    if(GetDigit(ans-1) + GetDigit(a) -1 > 18){
      over_flag = true;
    }
    ans *= a;
    if(ans > 1000000000000000000){
      over_flag = true;
    }
  }
  if(over_flag){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3196
#include<stdio.h>
int main()
{
    int A,B,C,D,R,L1,L2;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    L1=A;
    if(B<A)
        {L1=B;}
    L2=C;
    if(D<C)
        {L2=D;}
    R=L1+L2;
    printf("%d\n",R);
    return 0;
    }

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i, j, k, l, a, b[100100],c=0;


    cin>>a;
    for(i=0;i<a;i++)cin>>b[i];



    for(i=1;i<a;i++)
    {
        if(b[i]==b[i-1]){b[i]=INT_MIN;c++;}
    }

    cout<<c;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

#define DEBUG (0)

int main()
{
  int N = 0;
  int M = 0;
  ll sum = 0;
  int flag = 0;  /* 0:OK, 1:NG */

  cin >> N >> M;

//  int array[N];
  vector<int> array(N,0);
  for(int i = 0; i < N; i++){
    cin >> array[i];
    sum += array[i];
  }
  sort(array.begin(), array.end());
  reverse(array.begin(), array.end());

  for(int i = 0; i < M; i++){
#if DEBUG
    cout << "sum:" << sum << ", compare:" << (array[i] * 2 * M) << "\n";
#endif
    if((array[i] * 4 * M) < sum){
      flag = 1;
      break;
    }
  }

  if(flag == 0){
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }
#if DEBUG
  for(int i = 0; i < N; i++){
    cout << array[i] << " ";
  }
    cout << "\n";
#endif




}


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

int main(){
  const int MAX = 200000;
  int n, a[MAX], mid;
  unsigned long long result = 0;
  cin >> n;
  for(int i = 0; i < n; ++i){
     cin >> a[i];
     a[i] -= i + 1;
  }
  sort(a, a + n);
  if(n % 2 == 0) mid = (a[n/2 - 1] + a[n/2])/2;
  else mid = a[n/2];
  for(int i = 0; i < n; ++i){
    result += abs(a[i] - (mid));
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())

ret = float('inf')
for h0 in range(1, H):
    h1 = (H - h0) // 2
    h2 = H - h0 - h1
    if not (h1 == 0 or h2 == 0):
        S_max = max(h0 * W, h1 * W, h2 * W)
        S_min = min(h0 * W, h1 * W, h2 * W)
        ret = min(ret, S_max - S_min)

    w1 = W // 2
    w2 = W - w1
    if not (w1 == 0 or w2 == 0):
        S_max = max(h0 * W, (H - h0) * w1, (H - h0) * w2)
        S_min = min(h0 * W, (H - h0) * w1, (H - h0) * w2)
        ret = min(ret, S_max - S_min)
        
for w0 in range(1, W):
    h1 = H // 2
    h2 = H - h1
    if not (h1 == 0 or h2 == 0):
        S_max = max(H * w0, h1 * (W - w0), h2 * (W - w0))
        S_min = min(H * w0, h1 * (W - w0), h2 * (W - w0))
        ret = min(ret, S_max - S_min)

    w1 = (W - w0) // 2
    w2 = W - w0 - w1
    if not (w1 == 0 or w2 == 0):
        S_max = max(H * w0, H * w1, H * w2)
        S_min = min(H * w0, H * w1, H * w2)
        ret = min(ret, S_max - S_min)

print(ret)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
typedef tuple<ll, ll, ll> T;


int main() {
	ll A, B;
	string s;
	cin >> A >> B >> s;
	bool ok = true;
	for (int i = 0;i < s.size();i++) {
		if (i == A)
			ok = s[i] == '-';
		else
			ok = '0' <= s[i] && s[i] <= '9';
		if (!ok)
			break;
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	map<long long, int> mp;
	for(int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		if(mp.count(a)) {
			mp.erase(a);
		}
		else {
			mp[a]++;
		}
	}
	cout << mp.size() << endl;
	return 0;	
}


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

int main() {
    cout << fixed << setprecision(10);
    long long W, H, x, y;  cin >> W >> H >> x >> y;
    if (2 * x == W && 2 * y == H) {
        cout << H * W / 2.0 << " " << 1 << endl;
    } else {
        cout << H * W / 2.0 << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
def main
  nums_cnt = ARGF.gets.chomp.to_i
  nums = ARGF.gets.split.map(&:to_i)

  # 累積和
  s = 0
  accum_ary = nums.map do |n|
    s += n
    s
  end
  # pp accum_ary

  min_diff = nil

  # 2番目（真ん中）の区切りを決める
  # m_idx=2 の場合、2の前が区切り という意味
  l = 1
  r = 3
  2.upto(nums.length-2) do |m_idx|
    # しゃくとり法
    l_side_sum = accum_ary[m_idx-1] # left側の合計

    side_min_diff = nil
    ll_sum = lr_sum = 0
    # 左サイドの分割位置
    l.upto(m_idx-1) do |i|
      ll = accum_ary[i-1]
      lr = l_side_sum - ll
      diff = (ll - lr).abs
      if side_min_diff.nil? || diff < side_min_diff
        ll_sum, lr_sum = ll, lr
        side_min_diff = diff
        l = i
      else
        # 更新しなかった＝右端が行き過ぎた！
        break
      end
    end

    # しゃくとり法
    r_side_sum = accum_ary[-1] - l_side_sum # right側の合計

    side_min_diff = nil
    rl_sum = rr_sum = 0
    # 右サイドの分割位置
    r.upto(nums.length-1) do |i|
      rl = accum_ary[i-1] - l_side_sum
      rr = r_side_sum - rl
      diff = (rl - rr).abs
      if side_min_diff.nil? || diff < side_min_diff
        rl_sum, rr_sum = rl, rr
        side_min_diff = diff
        r = i
      else
        # 更新しなかった＝右端が行き過ぎた！
        break
      end
    end

    min, max = [ll_sum, lr_sum, rl_sum, rr_sum].minmax
    diff = max - min
    min_diff = diff if min_diff.nil? || diff < min_diff
  end

  puts min_diff
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 21772
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
const int MAXN = 2e5+5;
vector<bool>vis(MAXN,0);
vii adj(MAXN);
int cnt = 0;
void dfs(int v){
	vis[v] = 1;
	cnt++;
	for(int x:adj[v]){
		if(!vis[x]){
			dfs(x);
		}
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		if(!vis[i]){
			dfs(i);
			ans = max(ans,cnt);
			cnt = 0;
		}
	}
	cout<<ans;
}


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


void solve(){

}

int main(){
    int N,K;
    cin >> N >> K;
    map<int,int> m;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        if(m.count(tmp) == 0){
            m[tmp] = 1;
        } else { 
            m[tmp]++;
        }
    }
    vector<int> v;
    for(auto x: m){
        v.push_back(x.second);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    if(v.size() <= K){
        ans = 0;
    } else {
        for(int i = 0; i <= v.size() - 1 - K; i++){
            ans += v[i];
        }
    }
    cout << ans << endl;
}


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

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
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
import math

n = int(input())

def distance(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)
distance_sum=0

c=[0]*n
for i in range(n):
    coordinate=list(map(int,input().split()))
    c[i]=coordinate


for i in range(n-1):
    for j in range(i+1,n):
        distance_sum+=distance(c[i][0],c[i][1],c[j][0],c[j][1])
    
distance_sum*=2
distance_sum*=(n-1)
distance_sum=distance_sum/(n*(n-1))

print(distance_sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
    off;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        int n,k;
        cin>>n>>k;    
        string s;
        cin>>s;
        s[k-1]+=('a'-'A');
        cout<<s<<'\n';
    }
      return 0;
}

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

result = 'APPROVED'
for anum in anums:
    if (anum % 2 == 0) and not ((anum % 3 == 0) or (anum % 5 == 0)):
        result = 'DENIED'
        break

print(result)

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

const int MAXN = 210;

int N;
int a[MAXN];

int main() {
  scanf("%d", &N);
  for(int i = 0; i < 2*N; i++)
    scanf("%d", &a[i]);
  sort(a, a+2*N);
  int ans = 0;
  for(int i = 0; i < N; i++)
    ans += min(a[2*i], a[2*i+1]);
  printf("%d\n", ans);
}

Measured memory_bytes: 128