akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int l[n];
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l, l + n);
    int sm = 0;
    for(int i = 0; i < n - 1; i++){
        sm += l[i];
    }
    if (sm > l[n-1]) {
        puts("Yes");
    }else{
        puts("No");
    }
    
}

Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	var r, b int
	for i := 0; i < len(s); i++ {
		if s[i] == '0' {
			r++
		} else {
			b++
		}
	}
	fmt.Println(min(r, b) * 2)
}


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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;i>=m;i--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
string dec_bin(ll x){
    string result;
    while(x>0){
        result.push_back(x%2 + 48);
        x = (x-(x%2))/2;
    }
    reverse(result.begin(),result.end());
    return result;
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;

ll pow_2(ll factor){
    ll count = 0;
    while(factor%2==0){
        count+=1;
        factor/=2;
    }
    if(factor==1)return count;
    else return -1;
}

/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

int main(){
    godspeed
    ll t;
    cin>>t;
    if(t>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b < 24) {
		cout << a + b << endl;
	}
	else {
		cout << a + b - 24 << endl;
	}
}

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


#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

//ABC161D - Lunlun Number
int D() {
	ll ans = 0;
	int k;

	scani(k);

	vector<ll> lun(9, 0);
	for (ll i = 0; i < 9; i++)
		lun[i] = i + 1;
	for (int i = 0; i < 100000; i++) {
		switch (lun[i] % 10) {
		case 0:
			lun.push_back(lun[i] * 10 + lun[i] % 10);
			lun.push_back(lun[i] * 10 + lun[i] % 10 + 1);
			break;
		case 9:
			lun.push_back(lun[i] * 10 + lun[i] % 10 - 1);
			lun.push_back(lun[i] * 10 + lun[i] % 10);
			break;
		default:
			lun.push_back(lun[i] * 10 + lun[i] % 10 - 1);
			lun.push_back(lun[i] * 10 + lun[i] % 10);
			lun.push_back(lun[i] * 10 + lun[i] % 10 + 1);
			break;
		}
		if (100000 <= lun.size()) break;
	}
	printll(lun[k - 1]);

	return 0;
}

int main()
{
	D();
	return 0;
}


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

int main(){

long long  a,b;
cin>> a>> b ;
if(a%b==0)cout << a/b << endl;

else cout << a/b+1 << endl;
return 0;
}




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

public class Main {

    static BufferedReader br;
    static StringTokenizer st;

    public static void main(final String[] args) {
        br = new BufferedReader(new InputStreamReader(System.in));

        try {
            final int A = readInt();
            final int P = readInt();

            final Solver solver = new Solver();

            System.out.println(solver.solve(A, P));

        } catch (final IOException e) {
            e.printStackTrace();
        }
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }

    static long readLong() throws IOException {
        return Long.parseLong(next());
    }

    static int readInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double readDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static char readCharacter() throws IOException {
        return next().charAt(0);
    }

    static String readLine() throws IOException {
        return br.readLine().trim();
    }
}

class Solver {
    public int solve(final int A, final int P) {
        final int pieces = A * 3 + P;

        return pieces / 2;
    }
}

Measured memory_bytes: 21716
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	string s;
	cin>>s;
	int n=s.size();
	fo(i,n)
	{
		if(s[i]=='?')
			s[i]='D';
	}
	int ans=0;
	fo(i,n-1)
		ans+=(s[i]=='P' && s[i+1]=='D');
	fo(i,n)
		ans+=(s[i]=='D');
	cout<<s<<'\n';
	printclock;
}

Measured memory_bytes: 3924
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<stack>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
    char str[50];
    while(scanf("%s",str)!=EOF)
    {
        if(strcmp(str,"Sunny")==0) printf("Cloudy\n");
        else if(strcmp(str,"Cloudy")==0) printf("Rainy\n");
        else printf("Sunny\n");
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)
		cout<<"Left"<<endl;
	else if(a+b==c+d)
		cout<<"Balanced"<<endl;
	else
		cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int count=0;
    for (int i=0;i<n;i++) {
        if (deq[deq[i]-1]==i+1) {
            count++;
        }
    }
    cout<<count/2<<endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int R; cin >>R;
  double ans = R*2*M_PI;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (1010)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
#define mkp make_pair
int n,P,c[N],f[N],ans;
pair<int,int> a[N];
int getf(int x,int y){
	int ans=0;
	for(;ans<n*2&&ans*ans+y*y<x*x;ans++);
	return ans;
}
int getg(int x,int y){
	int ans=0;
	for(;ans<n*2&&ans*ans+y*y<=x*x;ans++);
	return ans;
}
int main(){
	read(n),read(P);
	for(int i=0;i<n;i++)a[i+1]=mkp(getf(n,i),-i);
	for(int i=n;i<2*n;i++)a[i+1]=mkp(getg(n*2,i),1);
	sort(a+1,a+2*n+1);
//	for(int i=1;i<=2*n;i++)
//	cout<<a[i].first<<" "<<a[i].second<<endl;
//	puts("-------------------");
	for(int i=0;i<n;i++)c[i]=getg(n*2,i);
	for(int k=0;k<=n;k++){
		memset(f,0,sizeof(f));
		f[0]=1; int s1=0,s2=0;
		for(int i=1;i<=2*n;i++)
		if(a[i].second==1){
//			cout<<a[i].first<<" "<<s1<<" faq"<<" "<<i<<endl;
			for(int j=0;j<=s2;j++)
			f[j]=(1ll*f[j]*(a[i].first-s1-j)%P+P)%P;
//			cout<<j<<" "<<f[j]<<" "<<a[i].first-s1-j<<endl;
			s1++;
		}
		else{
			for(int j=s2;j>=0;j--){
				f[j+1]=(0ll+f[j+1]+1ll*f[j]*(a[i].first-s1-j)%P+P)%P;
				f[j]=(1ll*f[j]*(c[-a[i].second]-n-k-s2+j)%P+P)%P;
//				cout<<j<<" "<<f[j]<<" "<<f[j+1]<<" "<<n+k+s2-j<<" "<<c[-a[i].second]<<endl;
			}
			s2++;
		}
//		cout<<k<<" "<<f[k]<<endl;
//		puts("-------");
		if(k&1)(ans+=P-f[k])%=P;else (ans+=f[k])%=P;
	}
	printf("%d\n",ans<0?ans+P:ans);
}

Measured memory_bytes: 2304
n= int(input())
x = []
u = []
for i in range(n):
    a,b = map(str,input().split())
    x.append(float(a))
    u.append(b)
    
ans = 0
for i in range(n):
    if u[i] == 'JPY':
        ans += x[i]
    if u[i] == 'BTC':
        ans += x[i] * 380000
print(ans)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias CSF = Tuple!(long, "c", long, "s", long, "f");

void main()
{
    auto N = readln.chomp.to!int;
    CSF[] ss;
    foreach (_; 0..N-1) {
        auto csf = readln.split.to!(long[]);
        ss ~= CSF(csf[0], csf[1], csf[2]);
    }
    long[] rs;
    foreach (i; 0..N-1) {
        long s;
        foreach (j; i..N-1) {
            s = max(s, ss[j].s);
            s += ss[j].c + ((s%ss[j].f == 0) ? 0 : (ss[j].f - s%ss[j].f));
        }
        rs ~= s;
    }
    rs ~= 0;
    foreach (r; rs) writeln(r);
}

Measured memory_bytes: 380
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll n; cin>>n;
    vector<ll> A(n);
    REP(i, n) cin>>A[i];
    ll res = 0;
    FOR(i, 1, n-1){
        if(A[i-1]<A[i] and A[i] < A[i+1]) res++;
        else if(A[i-1]>A[i] and A[i] > A[i+1]) res++;
    }
    cout << res << endl;
    return 0;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int x, n; cin >> x >> n;
    ForE(i, 1, n){ int y; cin >> y; x -= y;}
    if (x <= 0) Ptest("Yes");
    cout << "No";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N= sc.nextInt();
        int[] a = new int[N-1];
        int[] b = new int[N-1];
        int[] ans = new int[N];
        int K = 0;
        for(long i=0;i<N;i++)list.add(new ArrayList<Integer>());
		for(int i=0;i<N-1;i++){
			a[i]=sc.nextInt()-1;
			b[i]=sc.nextInt()-1;
			list.get(a[i]).add(b[i]);
			list.get(b[i]).add(a[i]);
		}
		
		for(int i=0;i<N;i++) {
			K=Math.max(K, list.get(i).size());
		}
		LinkedList<Integer> queue = new LinkedList<Integer>();
		queue.add(0);
		queue.add(1);
		boolean[] visited = new boolean[N];
		while(!queue.isEmpty()) {
			int now = queue.poll();
			int num = queue.poll();
			int sili = 1;
			visited[now]=true;
			ans[now]=num;
//			System.out.println("aaa"+list.get(now).size());
			for(int i=0;i<list.get(now).size();i++) {
//				System.out.println("aaa"+list.get(now).size());
				if(visited[list.get(now).get(i)]==true)continue;
				if(sili==num) {
					sili++;
				}
				if(sili>K) {
					sili=sili-K;
				}
				queue.add(list.get(now).get(i));
				queue.add(sili);
				sili++;
			}
			sili = 1;
//			System.out.println("aaa"+sili);
		}
		
		
	    System.out.println(K);
	    for(int i=0;i<N-1;i++) {
		       System.out.println(ans[Math.max(a[i], b[i])]);			
		}
    }
}

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

int main() {
  int n; cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int cnt = 0;
  for (int i = 1; i < n-1; i++) {
    int a = max(vec.at(i), max(vec.at(i-1), vec.at(i+1)) );
    int b = min(vec.at(i), min(vec.at(i-1), vec.at(i+1)) );
    if (vec.at(i)!=a) {
      if (vec.at(i) != b) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000

int main(){
  unsigned short *a,*b;
  int n,i,c[MAX+1];
  
  scanf("%d",&n);

  a=(short*)malloc((n+1)*sizeof(short));
  b=(short*)malloc((n+1)*sizeof(short));
  
  for(i=1;i<=n;i++) scanf("%hu",&a[i]);

  for(i=0;i<=MAX;i++){
    c[i]=0;
  }

  for(i=0;i<n;i++){
    c[a[i+1]]++;
  }

  for(i=1;i<MAX;i++){
    c[i]=c[i]+c[i-1];
  }

  for(i=n;i>0;i--){
    b[c[a[i]]]=a[i];
    c[a[i]]--;
  }
  
  for(i=1;i<n;i++) printf("%d ",b[i]);
  printf("%d\n",b[i]);

  free(a);
  free(b);
  
  return 0;
}



Measured memory_bytes: 9132
# coding: utf-8
# Your code here!

num_len = int(input())
num_list = list(map(int, input().split(" ")))
#print(num_list)
count = 0
while all(i % 2 == 0 for i in num_list):
    num_list =[j // 2 for j in num_list]
    count += 1
    
print(count)
    

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
vector<vector<int>>v_w, v_b;
vector<string>field;
int dx[] = { 1,0,-1,0 }, dy[] = { 0, 1, 0, -1 };
bool within(int x, int y) {
	return 0 <= x&&x < field.size() && 0 <= y&&y < field[0].size();
}
void color(int x, int y, char c, vector<vector<int>>&a) {
	if (a[x][y] != 0)return;
	a[x][y] = (c == 'W' ? 1 : -1);
	rep(i, 0, 4) {
		int X = x + dx[i], Y = y + dy[i];
		if (within(X, Y) && field[X][Y] == '.')color(X, Y, c, a);
	}


}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w, h;
	while (cin >> w >> h, w&&h) {
		field = vector<string>(h);
		rep(i, 0, h)cin >> field[i];
		int cnt_w(0), cnt_b(0);
		rep(i, 0, h)rep(j, 0, w) {
			if (field[i][j] == 'W')cnt_w++;
			else if (field[i][j] == 'B')cnt_b++;

		}
		v_w = v_b = vector<vector<int>>(h, vector<int>(w, 0));
		dump(cnt_w, cnt_b);
		rep(i, 0, h)rep(j, 0, w) {
			if (field[i][j] == 'W') {
				rep(k, 0, 4) {
					int a = i + dx[k], b = j + dy[k];
					if (within(a, b)&&field[a][b]=='.')color(a, b, 'W', v_w);
				}
			}
			else if (field[i][j] == 'B') {
				rep(k, 0, 4) {
					int a = i + dx[k], b = j + dy[k];
					if (within(a, b)&&field[a][b]=='.')color(a, b, 'B', v_b);
				}
			}
		}
		int result_w(0), result_b(0);
		rep(i, 0, h)rep(j, 0, w) {
			if (v_w[i][j] == 1 && v_b[i][j] == -1)continue;
			else if (v_w[i][j] == 1)result_w++;
			else if (v_b[i][j] == -1)result_b++;
		}
		cout << result_b << " " << result_w << endl;

	}
	return 0;
}

Measured memory_bytes: 3312
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

string s;
ll n, k, now, cnt = 1, ans;
bool ok = true;
int main() {
	cin >> s >> k;
	n = s.size();
	now = n;
	REP(i, n) {
		if (s[i] != s[0])ok = false;
	}
	if (ok) {
		cout << n * k / 2 << endl;
		return 0;
	}
	REPR(i, n - 1) {
		if (s[n - 1] == s[i]) {
			now--;
		}
		else break;
	}
	REP(i, now - 1) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
		else {
			ans += cnt / 2;
			cnt = 1;
		}
	}
	ans += cnt / 2;
	cnt = 1;
	s += s;
	ll a2 = 0;
	FOR(i, now, n + now) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
		else {
			a2 += cnt / 2;
			cnt = 1;
		}
	}
	a2 += cnt / 2;
	cnt = 1;
	ll a3 = (n - now) / 2;
	//cout << now <<endl;
	//cout << ans << " " << a2 << " " << a3 << endl;
	cout << ans + a2 * (k - 1) + a3 << endl;
	

}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    LL N;
    cin >> N;
    LL a[N];
    REP(i, N) {
        cin >> a[i];
    }
    LL ms = 1e18;
    for(LL i = -100;i <= 100;i++) {
        LL s = 0;
        REP(j, N) {
            s += pow(a[j] - i, 2);
        }
        ms = min(ms, s);
    }
    cout << ms << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int main() {
	int N, X, T;

	cin >> N >> X >> T;

	int ans = T * (N / X);
	if (N % X != 0) {
		ans += T;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3672
import java.util.*;

public class Main {

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

        if (a < 3200) {
            System.out.println("red");
        } else {
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if(b - a <= 0) puts("delicious");
	else if ( b - a <= x) puts("safe");
	else puts("dangerous");
}


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

vector<ll> divisor(ll n){
    vector<ll> vec;
    for(ll i=1;i*i<= n;i++){
        if(n%i==0){
            vec.push_back(i);
            if(i*i!=n) vec.push_back(n/i);
        }
    }
    //sort(vec.begin(), vec.end());
    return vec;
}

int main(void){
    int n;
    cin >> n;

    ll ans = 0;
    for(int i=1;i<=n;i++){
        ll y = n/i;
        ans += y*(y+1)*i/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x[2];
  int y[2];
  for(int i=1; i<3; i++){
    cin >> x[i] >> y[i];
  }
  int subx = x[2] - x[1];
  int suby = y[2] - y[1];
  int x3, x4, y3, y4;
  if(subx>=0 && suby>=0){
    x3 = x[2] - suby;
    y3 = y[2] + subx;
    x4 = x[1] - suby;
    y4 = y[1] + subx;
  }
  if(subx>=0 && suby<0){
    x3 = x[2] - suby;
    y3 = y[2] + subx;
    x4 = x[1] - suby;
    y4 = y[1] + subx;
  } 
  if(subx<0 && suby>=0){
    x3 = x[2] - suby;
    y3 = y[2] + subx;
    x4 = x[1] - suby;
    y4 = y[1] + subx;
  }
  if(subx<0 && suby<0){
    x3 = x[2] - suby;
    y3 = y[2] + subx;
    x4 = x[1] - suby;
    y4 = y[1] + subx;
  }
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 256
s = input()
s1 = int(s[0:2])
s2 = int(s[2:])


if s1 >= 1 and s1 <= 12:
	if s2 >= 1 and s2 <= 12:
		print('AMBIGUOUS')
	else:
		print('MMYY')

else:
	if s2 >= 1 and s2 <= 12:
		print('YYMM')
	else:
		print('NA')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main()
{
  int x,y;
  
  cin >> x >> y;
  
  bool is2x = (y%2==0);
  
  if(is2x && 2*x<=y && y<=4*x)
  {
    cout << "Yes" << endl;
  }
  else
  {
        cout << "No" << endl;
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    ll ans = 0;
    cin>>s>>k;
    ll n = s.length();
    bool prevflag = false;
    bool lastflag1 = false;

    //最初が大丈夫
    rep(i,s.length()){
        if(i==0){
            continue;
        }
        if(s[i]==s[i-1]&&!prevflag){
            ans++;
            prevflag = true;
        }else{
            prevflag = false;
        }
    }
    lastflag1 = prevflag;


    if(s[0]!=s[n-1] || lastflag1){
        ans*=k;
        cout<<ans<<endl;
        return  0;
    }

    //最初がダメ
    ll ans2 = 0;
    bool lastflag2 = false;
    rep(i,s.length()){
        if(i==0){
            ans2++;
            prevflag = true;
            continue;
        }
        if(s[i]==s[i-1]&&!prevflag){
            ans2++;
            prevflag = true;
        }else{
            prevflag = false;
        }
    }
    lastflag2 = prevflag;

    ll fans=0;
    if(lastflag2){
        fans = ans*((ll) (k+1)/2) + ans2 * ((ll) k/2);
    }else{
        fans = ans+ans2*(k-1);

    }
    cout<<fans<<endl;
    return  0;
}


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

const int N = 1e5 + 7;
bool mark[N];
int cnt[N];

int main()
{
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	mark[0] = 1;
	for (int i=0; i<n; i++)
		cnt[i] = 1;
	for (int i=0; i<m; i++)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		if (cnt[u] && mark[u])
			mark[v] = 1;
		cnt[u]--;
		cnt[v]++;
		if (cnt[u] == 0)
			mark[u] = 0;
	}
	int ans = 0;
	for (int i=0; i<n; i++)
		if (mark[i])
			ans++;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 768
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
   ll N,K;
   cin >> N >> K;
   vector<ll> H(N);
   rep(i,N)cin >> H[i];
   sort(H.begin(),H.end());
   if(K >= N)cout << 0 << endl;
   else{
     ll ans = 0;
     rep(i,N-K)ans += H[i];
     cout << ans << endl;
   }
}


Measured memory_bytes: 4736
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;
#define MAX_V 330

typedef long long ll;

int main(void) {
  int n;
  ll k, x;
  vector<ll> a, f;
  cin >> n >> k;
  rep(i, n) {
    cin >> x;
    a.push_back(x);
  }
  rep(i, n) {
    cin >> x;
    f.push_back(-x);
  }
  sort(a.begin(), a.end());
  sort(f.begin(), f.end());

  ll l = -1, r = 1000000000100;
  while (r - l > 1) {
    //cout << 1 << endl;
    ll med = (l + r) / 2;
    ll kk = k;
    rep(i, n) {
      if (a[i] * (-f[i]) > med) {
	kk -= a[i] - (med / (-f[i]));
      }
      if (kk < 0) {
	l = med;
	break;
      }
    }
    if (kk >= 0) r = med;
  }
  cout << r << endl;

  return 0;
}

Measured memory_bytes: 4848
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,k,cnt;
        int[] n = new int[990];
        String[] str = new String[990];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine().split(" ");
            for(i=0;i<2;i++){
                n[i]=Integer.parseInt(str[i]);   
            } 
            cnt=0;
            if(n[0]==0 && n[1]==0) break; 
            for(i=1;i<=n[0];i++){
                for(j=i+1;j<=n[0];j++){
                    for(k=j+1;k<=n[0];k++){
                        cnt+=(i+j+k==n[1] ? 1 : 0);
                    }
                } 
            }
            System.out.println(cnt);
        }
        System.out.flush();
    }
}

Measured memory_bytes: 25052
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N = cin.int()
    H = cin.mapInt()
    ans = 0
    now = 0
    for h in H:
        if now < h:
            ans += h - now
        now = h
    print(ans)
    return

if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i<n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans1 = a[n-1], ans2, m = 1e9;
  for(int i = 0; i<n; i++) {
    if (m > abs(ans1 - a[i] * 2)) {
      m = abs(ans1 - a[i] * 2);
      ans2 = a[i];
    }
  }
  cout << ans1 << " " << ans2;
}

Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
int i,j,k,l,t,n,m,mx,mi,cnt;
bool czy;
int main(){
	scanf("%d",&n);
	czy=1;
	mi=n+1;mx=0;
	fo(i,1,n){
		scanf("%d",&t);
		//mi=min(mi,t);
		if (t<mi) mi=t,cnt=1;
		else if (t==mi) cnt++;
		if (i>1&&czy&&t!=mx) czy=0;
		mx=max(mx,t);
	}
	if (czy){
		if (mx==n-1) printf("Yes\n");
		else{
			k=mx;
			if (k*2<=n) printf("Yes\n");
			else printf("No\n");
		}
	}
	else{
		if (mx-mi>1) printf("No\n");
		else{
			k=mx;
			if (cnt<k&&n-cnt>=(k-cnt)*2) printf("Yes\n");
			else printf("No\n");
		}
	}
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>


using namespace std;

#define DUMP(x) cout << #x << ": " << x << endl

int n;
int memo[310][310] = { false };
int dp[310] = { 0 };

vector<int> w(n);

int rec(int l, int r) {
  if (r - l == 0) {
    return memo[l][r] = 2;
  }
  if (r - l == 1) {
    return memo[l][r] = 1;
  }
  
  if (r - l  - 1 == 1) {
    if (abs(w[r - 1] - w[l]) <= 1) {
      return memo[l][r] = 2;
    }
  }
  if (memo[l][r]) {
    return memo[l][r];
  }

  for (int t = l + 1; t < r; t++) {
    int temp  = rec(l, t);
    int temp2 = rec(t, r);
    int temp3 = rec(l + 1, t);
    int temp4 = rec(t, r - 1);
    
    if (temp == 2 && temp2 == 2) {
      return memo[l][r] = 2;
    }
    if (abs(w[l] - w[r - 1]) <= 1 && temp3 == 2 && temp4 == 2) {
      return memo[l][r] = 2;
    }
  }

  return memo[l][r] = 1;
}

int main() {
  while (true) {
    cin >> n;
    if (n == 0) {
      break;
    }

    w.clear();
    w.resize(n);

    for (int i = 0; i < n; i++) {
      cin >> w[i];
    }
    memset(memo, 0, sizeof(memo));
    memset(dp, 0, sizeof(dp));
    
    //    cerr << " " << rec(0, n) << endl;
    rec(0, n);

    
    dp[0] = 0;

    for (int r = 0; r <= n; r++) {
      dp[r] = dp[r - 1];
      for (int l = 0; l < r; l++) {
        if (memo[l][r] == 2) {
          dp[r] = max(dp[r], dp[l] + (r - l));
        }
      }
    }
    

    cout << dp[n] << endl;

  }

  

  return 0;
}

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

bool my_sqrt(int x) {
    for (int i = 2; i <= sqrt(x); i++) 
        if (x % i == 0) return false;

    return true;
}

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

    int r = 0;
    while (r == 0) {
        if (my_sqrt(x)) {
            r = x;
        } else {
            x++;
        }
    }

    cout << r << endl;

    return 0;
}


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

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 int INF = 1000000000;
int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];

  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  sort(r.begin(), r.end(), greater<int>());

  int tmp_x = x - 1;
  int tmp_y = y - 1;
  for(int i = 0; i < r.size(); ++i){
    if(r[i] < p[tmp_x] && r[i] < q[tmp_y]) break;
    if(p[tmp_x] < q[tmp_y]){
      if(0 <= tmp_x){
        p[tmp_x] = max(p[tmp_x], r[i]);
        tmp_x--;
      }
      else if(0 <= tmp_y){
        q[tmp_y] = max(q[tmp_y], r[i]);
        tmp_y--;
      }
    }
    else if(p[tmp_x] > q[tmp_y]){
      if(0 <= tmp_y){
        q[tmp_y] = max(q[tmp_y], r[i]);
        tmp_y--;
      }
      else if(0 <= tmp_x){
        p[tmp_x] = max(p[tmp_x], r[i]);
        tmp_x--;
      }
    }
    else{
      if(tmp_x < tmp_y){
        q[tmp_y] = max(q[tmp_y], r[i]);
        tmp_y--;
      }
      else{
        p[tmp_x] = max(p[tmp_x], r[i]);
        tmp_x--;
      }
    }
  }

  ll ans = 0;
  for(int i = 0; i < x; ++i){
    ans += p[i];
  }
  for(int i = 0; i < y; ++i){
    ans += q[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct edge {
	int to;
	ll cost;
};
vector<edge> G[100010];
int ans[100010];
void dfs(int v, int parent, ll dist) {
	ans[v] = dist % 2;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i].to == parent) continue;
		dfs(G[v][i].to, v, dist + G[v][i].cost);
	}
}
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	dfs(0, -1, 0);
	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
int MAX_N=100100;




int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<int> Num(100010, 0);
    int MaxNum=0;
    int Kaburi=0;
    for(int i=0; i<N; i++){
        cin>>A[i];
        A[i]--;
        if(Num[A[i]]>0){
            Kaburi ++;
        }
        Num[A[i]] ++;
        MaxNum=max(MaxNum, Num[A[i]]);
      	//cout<<MaxNum<<endl;
    }
  	//cout<<MaxNum<<endl;
    if(Kaburi+2>=MaxNum){
        cout<<N-((Kaburi+1)/2)*2<<endl;
        return 0;
    }
    MaxNum --;
    N -= 2*(Kaburi-MaxNum);
    MaxNum-=Kaburi;
    int Ans=max(N-2*MaxNum, 1);
    cout<<Ans<<endl;
    return 0;
    
    
}

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

int euclid(int a, int b) {
  if (b == 0) return a;
  return euclid(b, a%b);
}

int main() {
  int N, X;
  cin >> N >> X;
  int x[N];
  rep(i, N) cin >> x[i];
  int dif[N];
  rep(i, N) dif[i] = abs(x[i]-X);
  int ans = dif[0];
  rep(i, N) ans = euclid(ans, dif[i]);
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
	vector<P> p(M);
	vector<P> q(M);
	set<ll> s;
	rep(i,M){
		ll A,B; cin>>A>>B;
		p[i]=mp(A,B);
		q[i]=mp(B,A);
	}
	sort(p.bg,p.ed);
	sort(q.bg,q.ed,greater<P>());
	ll i=0;
	while(i<M){
		if(p[i].a!=1) break;
		else{
			s.insert(p[i].b);
			i++;
		}
	}
	bool ans=false;
	i=0;
	while(i<M){
		if(q[i].a!=N) break;
		else{
			auto itr=s.find(q[i].b);
			if(itr!=s.end()){
				ans=true;
			}
			i++;
		}
	}
	if(ans) cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
}

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

typedef long long ll;
int main(){
  string s;
  cin>>s;
  if(s[0]!='A')
    {cout<<"WA"; return 0;}
    ll cnt=0;
  for(int i=1;i<s.size();i++)
  {
      if(s[i]=='C'&&i>1&&i<s.size()-1)
        cnt++;
     else if('A'<=s[i]&&s[i]<='Z')
        {cout<<"WA"; return 0;}
  }
  if(cnt==1)
    cout<<"AC"<<endl;
  else
    cout<<"WA";
}
    
    


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc145/submissions/8698269

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EAllyoucaneat solver = new EAllyoucaneat();
        solver.solve(1, in, out);
        out.close();
    }

    static class EAllyoucaneat {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int t = in.nextInt();
            int[] a = new int[n + 1];
            int[] b = new int[n + 1];
            ArrayList<Pair> alp = new ArrayList<Pair>();
            alp.add(new Pair(0, 0));
            int[][] dp = new int[n + 1][t + 2]; // dp[i][j] -> maximum value from 1 to i, within j min
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                alp.add(new Pair(a[i], b[i]));
            }
            Collections.sort(alp, Comparator.comparing(x -> x.time));
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= t; j++) {
                    // dp[i][j] = dp[i-1][j-a[i]] -> Add or dp[i-1][j] NoAdd
                    if (j - alp.get(i).time >= 0) {
                        dp[i][j] = Math.max(dp[i - 1][j - alp.get(i).time] + alp.get(i).val, dp[i - 1][j]);
                    } else {
                        // Add -> cannot
                        dp[i][j] = dp[i - 1][j];
                    }
                }
                dp[i][t + 1] = Math.max(dp[i - 1][t - 1] + alp.get(i).val, dp[i - 1][t + 1]);
            }
            out.println(dp[n][t + 1]);

        }

    }

    static class Pair {
        int time;
        int val;

        public Pair(int x, int y) {
            this.time = x;
            this.val = y;
        }

    }
}



Measured memory_bytes: 86520
N = int(input())
T = [int(i) for i in input().split()]
T_SUM = sum(T)
M = int(input())
PX = [tuple(map(int,input().split())) for _ in range(M)]
for px in PX:
  time = T_SUM + px[1] - T[px[0]-1]
  print(time)

Measured memory_bytes: 9176
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    c=10**5+1
    # S[i]: iがprimeかを指すboolean
    S=[1]*c
    S[0]=0; S[1]=0
    for i in range(2,c):
        if S[i]==0: continue
        for j in range(2*i,c,i):
            S[j]=0
    # T[i]: iが2017-like primeかを指すboolean
    T=[0]*c
    for i in range(3,c,2):
        if S[i] and S[(i+1)//2]:
            T[i]=1
    # cumsum
    for i in range(c-1):
        T[i+1]+=T[i]
    # input
    q=int(input())
    for _ in range(q):
        l,r=map(int,input().split())
        print(T[r]-T[l-1])
resolve()

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

int main(void){
    int a = 0, b = 0, c = 0, d = 0; 

    scanf("%d%d%d%d", &a, &b, &c, &d);

    fprintf(stderr,"abs(a-b) = %d abs(b-c) = %d d = %d\n", abs(a-b), abs(b-c), d);
    if(d >= abs(a-b) && d >= abs(b-c)){
        printf("Yes\n");
    }else if(d >= abs(a-c)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n, k);

  puts((int)ceil(1.0 * n / 2) >= k ? "YES" : "NO");

  return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, N):
        self.N = N
        self.parent = [-1] * N

    def root(self, A):
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])
        return self.parent[A]

    def size(self, A):
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        A = self.root(A)
        B = self.root(B)

        if (A == B):
            return False

        if (self.size(A) < self.size(B)):
            A, B = B, A

        self.parent[A] += self.parent[B]
        self.parent[B] = A

        return True

    def is_in_same(self, A, B):
        return self.root(A) == self.root(B)


N, M = map(int, input().split())
uf = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(N):
  ans = max(ans, uf.size(i))

print(ans)


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

int main(){
  int n,m,c,b[100],a[100][100];
  cin >> n >> m >> c;
  FOR(i,m){
    cin >> b[i];
  }
  FOR(i,n){
    FOR(j,m){
      cin >> a[i][j];
    }
  }
  int v,ans=0;
  FOR(i,n){
    v=0;
    FOR(j,m){
      v+=(a[i][j]*b[j]);
    }
    v+=c;
    if(v>0){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int N, M, A[10], nums[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int INF = 1000000000;

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++) cin >> A[i];

    vector< pair<int, int> > p(M);
    for(int i=0;i<M;i++){
        p[i] = make_pair(A[i], nums[A[i]]);
    }

    sort(p.begin(), p.end(), greater< pair<int, int> >());

    vector<int> DP(N+1);    //DP[i]はちょうどi本使って最大何桁作れるか
    DP[0] = 0;

    for(int i=1;i<=N;i++){
        DP[i] = -INF;
        for(int j=0;j<M;j++){
            if( 0 <= i - p[j].second ) DP[i] = max(DP[i], DP[ i - p[j].second ] + 1);
        }
    }

    vector<int> ans;
    while( N > 0 ){
        for(int i=0;i<M;i++){
            if( 0 <= N-p[i].second ){
                if( DP[N - p[i].second ] == DP[N] - 1 ){
                    ans.push_back(p[i].first);
                    N -= p[i].second;
                    break;
                }
            }
        }
    }

    for(auto i : ans)   cout << i;
    cout << endl;
}

Measured memory_bytes: 384
n, m, X, Y = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))
xlist.append(X)
ylist.append(Y)
xlist.sort()
ylist.sort()

if xlist[-1] < ylist[0]:
   print("No War")
else:
   print("War")


Measured memory_bytes: 3060
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(3)] for i in range(3)]

bingo=[[0 for j in range(3)] for i in range(3)]

for i in range(3):
    Z=list(map(int,input().split()))
    for j in range(3):
        S[i][j]=Z[j]
        
N=int(input())

for k in range(N):
    tama=int(input())
    for i in range(3):
        for j in range(3):
            if tama==S[i][j]:
                bingo[i][j]=1

if bingo[0][0] ==1 and bingo[0][1] ==1 and bingo[0][2]==1 or bingo[1][0] ==1 and bingo[1][1] ==1 and bingo[1][2]==1 or bingo[2][0] ==1 and bingo[2][1] ==1 and bingo[2][2]==1 or bingo[0][0] ==1 and bingo[1][0] ==1 and bingo[2][0]==1 or bingo[0][1] ==1 and bingo[1][1] ==1 and bingo[2][1]==1 or bingo[0][2] ==1 and bingo[1][2] ==1 and bingo[2][2]==1 or bingo[0][0] ==1 and bingo[1][1] ==1 and bingo[2][2]==1 or bingo[2][0] ==1 and bingo[1][1] ==1 and bingo[0][2]==1: 
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064