akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let a: Vec<Vec<char>> = (0..h)
        .map(|_| sc.read::<String>().chars().collect())
        .collect();

    let mut red = vec![vec!['.'; w]; h];
    let mut blue = vec![vec!['.'; w]; h];
    for i in 0..h {
        for j in 0..w {
            if i % 2 == 0 {
                red[i][j] = '#';
            } else {
                blue[i][j] = '#';
            }
        }

        red[i][0] = '#';
        red[i][w - 1] = '.';
        blue[i][0] = '.';
        blue[i][w - 1] = '#';
    }

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                red[i][j] = '#';
                blue[i][j] = '#';
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            print!("{}", red[i][j]);
        }
        println!();
    }
    println!();
    for i in 0..h {
        for j in 0..w {
            print!("{}", blue[i][j]);
        }
        println!();
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 6908
import java.util.Stack;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Comparator;

class Sheet
{
	private byte n;
	private byte [][] t = new byte[10][10];
	private Stack<String> st = new Stack<String>();
	
	private final static int[][][] inkPos = 
	{
		{
			{-1, 0} , {1, 0} , {0,-1} , {0, 1}, {0,0}
		},
		{
			{-1,-1} , {-1,1} , {1,-1} , {1, 1}
		},
		{
			{-2, 0} , {0, 2} , {2, 0} , {0,-2}
		}
	};
	
	
	private boolean isInside(int i, int j)
	{
		return i<10 && j<10 && i>=0 && j>=0;
	}
	
	private boolean droppable_(int ink, int i, int j)
	{
		for(int a = 0; a <= ink; ++a) {
			for(int[] r : inkPos[a]) {
				int ci = i + r[0];
				int cj = j + r[1];
				
				if( !isInside(ci,cj) ){
					return false;
				}
				
				if( t[ci][cj] < 1 ) {
					return false;
				}
			}
		}
		return true;
	}
	
	private boolean operateInk(int ink, int i, int j, int op)
	{
		boolean ret = false;
		for(int a = 0; a <= ink; ++a) {
			for( int[] r : inkPos[a] ) {
				int ci = i + r[0];
				int cj = j + r[1];
				
				if( op == 0 ) {
					// drop ink
					t[ci][cj]--;
					if( t[ci][cj] == 0 ) ret = true;
				} else {
					// remove ink
					if( t[ci][cj] == 0 ) ret = true;
					t[ci][cj]++;
				}
			}
		}
		return ret;
	}
	
	public void solve(int pi, int pj, int pa)
	{
		
		int maxVal = 0;
		int rem = 0;
		for(int i = 0; i < t.length; ++i) {
			for(int j = 0; j < t[i].length; ++j) {
				
				if( t[i][j] > 0 ) {
					rem+=t[i][j];
				}
				if( t[i][j] > maxVal ) {
					maxVal = t[i][j];
				}
			}
		}

		// the number of remaining operations is enough to clear
		if( n < maxVal || 13*n < rem ) {
			return ;
		}
		
		if( n == 0 ){

			for(int i = 0; i < t.length; ++i) {
				for(int j = 0; j < t[i].length; ++j) {
					if( t[i][j] != 0 ) {
						return ;
					}
				}
			}
	
			while( !st.empty() ) {
				System.out.println(st.pop());
			}
			
		}else{
			
			for(int i = 0; i < t.length; ++i){
				for(int j = 0; j < t[i].length; ++j){
					
					if( t[i][j] > 0 ) {
						boolean ret = false;

						for(int a = 0; a <= 2; ++a){
							for(int[] r : inkPos[a]){
								int ci = i+r[0];
								int cj = j+r[1];

								if( droppable_(a,ci,cj) ) {
									ret = true;
								}
							}
						}
						
						// exist a cell that cannot be zero by dropping ANY inks around there.
						if( !ret ) {
							return ;
						}
					}
				}
			}
			
			for(int a = pa; a >= 0; --a){
				for(int i = a==pa?pi:1; i < 9; ++i) {
					for(int j = a==pa&&i==pi?pj:1; j < 9; ++j) {
						
						if( droppable_(a,i,j) ){
							
							// progress state
							--n;
							operateInk(a,i,j,0);
							st.push(j+" "+i+" "+(a+1));
							
							solve( i, j, a );
							if( st.empty() ) return ;
							
							// rollback state
							++n;
							st.pop();
							operateInk(a,i,j,1);
						}
					}
				}
			}
		}
	}
	
	public void input()
	{
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextByte();
		for(byte[] f : t) {
			for(int i = 0; i < f.length; ++i){
				f[i] = sc.nextByte();
			}
		}
	}
}

class Main
{
	public static void main(String [] args)
	{
		Sheet sheet = new Sheet();
		sheet.input();
		sheet.solve( 1, 1, 2 );
	}
}

Measured memory_bytes: 45780
import sys
import math



s = int(input())
rolls = []
count = 0
flag = False
while s:
	temp = [int(x) for x in input().split()]
	if temp[0] == temp[1]:
		count += 1
	else:
		count = 0

	if count == 3:
		flag = True





	s -= 1

if flag:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>
#include<regex>
#include<math.h>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}


int main() {
	lli n;
	cin >> n;
	cout << (n) * (n - 1) / 2;
	
}


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

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

	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}

	else {
		cout << "B" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int A, B, C;
  cin >>  A >>B>>C;
  int a[3];
  a[0]=abs(A-B);
  a[1]=abs(B-C);
  a[2]=abs(C-A);

  sort(a, a+3);
  cout << a[0]+a[1];


  return 0;
}


Measured memory_bytes: 256
input_ = input()
a = int(input_.split(' ')[0])
b = int(input_.split(' ')[1])
c = int(input_.split(' ')[2])
k = int(input())
count = 0
ans = "No"
while count < k:
  if a >= b:
    b *= 2
    count += 1
  elif b >= c:
    c *= 2
    count += 1
  if a < b and b < c:
    ans = "Yes"
    break

print(ans)


Measured memory_bytes: 9184
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,i,j,temp,min:Integer;
  d:array of Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);
    SetLength(d,n);
    for i:=0 to n-1 do
      Readln(d[i]);

    for i := 0 to n-1 do begin
      min := i;
      for j := i+1 to n-1 do begin
        if d[j] < d[min] then
        min := j;
      end;
      temp:=d[i];
      d[i]:=d[min];
      d[min]:=temp;
    end;

    for i := 0 to n - 2 do begin
      if d[i]=d[i+1] then
        n:=n-1;
    end;

    Writeln(n);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,i,j,temp,min:Integer;
  d:array of Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);
    SetLength(d,n);
    for i:=0 to n-1 do
      Readln(d[i]);

    for i := 0 to n-1 do begin
      min := i;
      for j := i+1 to n-1 do begin
        if d[j] < d[min] then
        min := j;
      end;
      temp:=d[i];
      d[i]:=d[min];
      d[min]:=temp;
    end;

    for i := 0 to n - 2 do begin
      if d[i]=d[i+1] then
        n:=n-1;
    end;

    Writeln(n);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

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

    sort(a.begin(),a.end());

    LL ans = 0;

    LL m = a[0];
    for(int i = 1; i < n; i++){
        LL ok = 0;
        LL ng = a[i]/n + 1;
        while(abs(ok-ng) > 1){
            LL middle = (ok+ng)/2;
            if((a[i] - middle*n) - (m + middle) < 0){
                ng = middle;
            }else{
                ok = middle;
            }
        }
        ans += ok;
        a[i] -= ok*n;
        for(int j = 0; j < n; j++){
            if(i != j){
                a[j] += ok;
            }
        }
        m = a[0];
    }

    LL dist = m - n + 1;
    if(dist < 0){
    }else{
        ans += dist*n;
        for(int i = 0; i < n; i++){
            a[i] -= dist;
        }
    }
        bool frag = true;
        while(frag){
            frag = false;
            for(int i = 0; i < n; i++){
                if(a[i] >= n){
                    ans++;
                    frag = true;
                    a[i] -= n;
                    for(int j = 0; j < n; j++){
                        if(i != j){
                            a[j]++;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    
    
    return 0;
}

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

lis = []

for i in range(n):
    s, p = input().split()
    lis.append([i+1, s, p])
    
lis.sort(key=lambda x: x[1])

names =[]

for i in lis:
    if i[1] not in names:
        names.append(i[1])
        
score = 100000


for name in names:
    for l in lis:
        if name in l:
            l[2] = int(l[2]) + score
        else:
            score -= 200
            
lis.sort(key=lambda x: x[2], reverse=True)
            
for i in lis:
    print(i[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> j(3);
  int five = 2;
  int seven = 1;
  for (int i=0; i<3; i++) {
    int t;
    cin >> t;
    j.at(i) = t;
    if (j.at(i) == 5) {
      five--;
    }
    if (j.at(i) == 7) {
      seven--;
    }
  }
  if (five == 0 && seven == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
    int K;int N;
    cin >> K >> N;
    int X[N];
    for (int i = 0; i < N; ++i) cin >> X[i];
    sort(X, X+N);
    int diffs[N-1];
    for (int i = 0; i < N-1; ++i) diffs[i] = X[i+1] - X[i];
    sort(diffs, diffs+N-1);
    long long res = 0;
    for (int i = 0; i < N-K; ++i) res += diffs[i];
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(N), B(N);
    for (int i=0; i<N;i++)
        cin>>A[i]>>B[i];
    vector<int> L(M), R(M);
    for (int i=0; i<M; i++)
        cin>>L[i]>>R[i];

    vector<pair<int, int>> AB(N);
    for (int i=0; i<N; i++)
        AB[i] = make_pair(A[i], B[i]);
    sort(AB.begin(), AB.end());
    for (int i=0; i<N; i++)
        A[i] = AB[i].first,
        B[i] = AB[i].second;

    A.push_back(1000000001);
    B.push_back(0);
    vector<int> C(N+1);
    C[0] = B[0];
    for (int i=1; i<=N; i++)
        C[i] = B[i-1]^B[i];

    vector<vector<int>> E(N+1);
    vector<vector<int>> EI(N+1);
    for (int i=0; i<M; i++)
    {
        int x = int(lower_bound(A.begin(), A.end(), L[i])-A.begin());
        int y = int(lower_bound(A.begin(), A.end(), R[i]+1)-A.begin());
        E[x].push_back(y);
        EI[x].push_back(i);
        E[y].push_back(x);
        EI[y].push_back(i);
    }

    vector<bool> V(N+1);
    vector<int> ans;

    function<int (int)> f = [&](int p)
    {
        if (V[p])
            return 0;
        V[p] = true;

        int s = C[p];
        for (int i=0; i<(int)E[p].size(); i++)
            if (f(E[p][i]) != 0)
            {
                ans.push_back(EI[p][i]);
                s ^= 1;
            }
        return s;
    };

    for (int r=0; r<=N; r++)
        if (!V[r])
            if (f(r)!=0)
            {
                cout<<-1<<endl;
                return 0;
            }
    
    sort(ans.begin(), ans.end());
    cout<<ans.size()<<endl;
    for (int i=0; i<(int)ans.size(); i++)
        cout<<(i==0 ? "" : " ")<<ans[i]+1;
    cout<<endl;
}


Measured memory_bytes: 22256
n = int(input())
A = list(map(int, input().split()))

ca = [0]
da = {'0': 1}
for i in range(n):
    ca.append(A[i]+ca[i])

    if str(ca[i+1]) in da:
        da[str(ca[i+1])] = da[str(ca[i+1])]+1
    else:
        da[str(ca[i+1])] = 1
# print(ca)
# print(da)

ans = 0
for k in da:
    ans += da[k]*(da[k]-1)//2
print(ans)


Measured memory_bytes: 49744
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

int a[300100];

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	FOR(i, 0, n * 3) {
		scanf("%d", &a[i]);
	}
	sort(a, a + 3 * n);
	LL res = 0;
	int idx = 3 * n - 2;
	FOR(i, 0, n) {
		res += a[idx];
		idx -= 2;
	}
	cout << res << endl;


#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double R;
    cin >> R;
    cout << fixed << setprecision(6) << 2 * R * M_PI;
    return 0;
}


Measured memory_bytes: 3780
//https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_A
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <functional>

template<typename T>
class monoid{
private:
    typedef std::function<T(T,T)> F;
    F cal;
    T id;
public:
    monoid(F f,T id):cal(f),id(id){}
    constexpr T operator()(T a,T b){
        return cal(a,b);
    }
    constexpr T get_id(){return id;}
};

//cut begin
template <typename T,typename E=T>
struct SegmentTree{
private:
    using G=std::function<T(T,E)>;
    int n;
    std::vector<T> init;
    monoid<T> mono;
    G upd;//function for update
    std::vector<T> node;

public:
    explicit SegmentTree(
            int sz,
            monoid<T> mono,
            G upd
    ):mono(mono),upd(upd)
    {
        n=1;
        while(n<sz)n=n*2;
        node.resize(static_cast<unsigned int>(2 * n - 1), mono.get_id());
        for (int i = 0; i <sz ; ++i) node[i+n-1]=mono.get_id();
        for (int i = n-2; i >= 0 ; --i) node[i]=mono(node[2*i+1],node[2*i+2]);
    }

    explicit SegmentTree(
            int sz,
            monoid<T> mono,
            G upd,
            std::vector<T> init
    ):mono(mono),upd(upd),init(init)
    {
        n=1;
        while(n<sz)n=n*2;
        node.resize(static_cast<unsigned int>(2 * n - 1), mono.get_id());
        for (int i = 0; i <sz ; ++i) node[i+n-1]=init[i+1];
        for (int i = n-2; i >= 0 ; --i) node[i]=mono(node[2*i+1],node[2*i+2]);
    }

    void update(int x, E val){//x:0-indexed
        x+=n-1;
        node[x]=upd(node[x],val);
        while(x>0){
            x=(x-1)/2;
            node[x]=mono(node[2*x+1],node[2*x+2]);
        }
    }

    T query(int p,int q,int k=0,int l=0,int r=-1){//[p,q):0-indexed
        if(r<0)r=n;
        if(r<=p||l>=q)return mono.get_id();//out of range
        if(p<=l&&r<=q)return node[k];

        return mono(query(p,q,2*k+1,l,(l+r)/2),query(p,q,2*k+2,(l+r)/2,r));
    }
};
//cut end
void solve(){
    int n,q;
    std::cin>>n>>q;
    monoid<int> mono([](int a,int b){return std::min(a,b);},std::numeric_limits<int>::max());
    SegmentTree<int> st(n,
        mono,
        [](int a,int b){return b;}
    );
    for(int i = 0; i < q; i++)
    {
        int com,x,y;
        std::cin>>com>>x>>y;
        if(com==0)//update
        {
            st.update(x,y);
        }
        else //find
        {
            std::cout<<st.query(x,y+1)<<std::endl;
        }
    }
}

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


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

#define ios                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define fr freopen("in.txt", "r", stdin)
#define ll long long
#define F first
#define S second
#define mem(v, x) memset(v, x, sizeof(v))
#define EB emplace_back
#define PB push_back
#define MP make_pair

int main()
{
    // fr;
    ios;

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

    for (int x = 1; x <= 10000; x++)
    {
        int chk1 = double(.08 * x);
        int chk2 = double(.1 * x);
        if (chk1 == a and chk2 == b)
        {
            cout << x;
            return 0;
        }
    }
    cout << "-1\n";
}

Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

int main(){

	string str;
	cin >> str;

	int n=str.size();
	rep(i,n)
	cout << str[n-1-i];
	cout << endl;

    return 0;

}

Measured memory_bytes: 1172
from fractions import gcd
from functools import reduce

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A = [i >> 1 for i in A]


def applied_lcm(x, y):
    g = gcd(x, y)
    x //= g
    y //= g
    if x % 2 == 0 or y % 2 == 0:
        return 0
    n = x * y * g
    if n >> 10 ** 9:
        return 0

    return n


p = reduce(applied_lcm, A)
if p == 0:
    ans = 0
else:
    ans = (M // p) - (M // (p + p))
print(ans)


Measured memory_bytes: 16308
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define mp(a,b) make_pair(a,b)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k,s;
    cin>>n>>k>>s;
   // return 0;
    if(s!=(int)(1e9)){
        for(int i=0;i<k;i++){
            cout<<s<<" ";
        }
        for(int i=0;i<n-k;i++){
            cout<<s+1<<" ";
        }
        return 0;
    }/*
    if(k==n){
        for(int i=0;i<n;i++) cout<<s<<" ";
        return 0;
    }
    for(int i=0;i<k;i++){
        if(i%2==0) cout<<s-1<<" ";
        else cout<<1<<" ";
    }
    for(int i=0;i<n-k;i++){
        if(k%2==0) cout<<s-1<<" ";
        else cout<<1<<" ";
    }*/
    for(int i=0;i<k;i++) cout<<s<<" ";
    for(int i=0;i<n-k;i++) cout<<1<<" ";
        return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void) {
	int n, k;
	scanf("%d %d", &n, &k);
	if (n % 2 == 0) {
		if (n / 2 >= k)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else
	{
		if (n / 2 >= k-1)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
int main(){
    int n,x,ans,aa=-1,bb=-1,cc=-1;
    cin >>n>>x;
    for(int i=0;i<=n;i++){
        for(int j=0;i+j<=n;j++){
            ans = i*10000+j*5000+(n-i-j)*1000;
            if(ans==x){
                aa=i;
                bb=j;
                cc=n-i-j;
            }
        }
    }
    cout << aa << " " << bb << " "<< cc << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> a)
{
    map<ll, ll> cnt;

    for (int i = 0; i < N; i++)
    {
        cnt[a[i]]++;
    }
    bool ans = false;
    if (cnt.size() == 3)
    {
		ll b[3];
		ll d[3];
		ll c = 0;
		for (auto i : cnt)
		{
			b[c] = i.second;
			d[c] = i.first;
			++c;
		}
 
		std::sort(b, b + 3);
 
		if (N % 3 == 0 && ((d[0]^d[1])==d[2])&&((d[0]^d[2])==d[1])&&((d[1]^d[2])==d[0]))
		{
			if (b[0] == b[1] && b[1] == b[2] && b[0] == b[2]) ans = true;
		}

    }
    else if (cnt.size() == 2)
    {
		ll b[2];
		ll d[2];
		ll c = 0;
		for (auto i : cnt)
		{
			b[c] = i.second;
			d[c] = i.first;
			++c;
		}
 
		std::sort(b, b + 2);
		std::sort(d, d+ 2);
		if (N % 3 == 0)
		{
			if (cnt[d[1]] == cnt[d[0]] * 2 && d[0] == 0) ans = true;
		}

    }
    else if (cnt.size() == 1)
    {
        if (cnt[0] == N)
        {
            ans = true;
        }
    }

    cout << (ans ? YES : NO) << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define INF (1e9)
#define s second
#define f first
#define N 50
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
typedef pair<int,P1> P2;
int x,y,stx,sty,skx,sky;
int d[N][N][N][N];
int dat[N][N];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
 
int bfs(){
  queue<P2> q;
  d[sty][stx][sky][skx]=0;
  q.push(P2(0,P1(P(sty,stx),P(sky,skx))));
  while(!q.empty()){
    P2 t=q.front(); q.pop();
    int cost=t.f;
    int ty=t.s.f.f,tx=t.s.f.s;
    int ky=t.s.s.f,kx=t.s.s.s;
    if(d[ty][tx][ky][kx]<cost)continue;
    if(ty==ky&&tx==kx)return cost;
    for(int i=0;i<4;i++){
      int nty=ty+dy[i],ntx=tx+dx[i];
      int nky=ky-dy[i],nkx=kx-dx[i];
      if(nty<0||ntx<0||y<=nty||x<=ntx)
    nty=ty,ntx=tx;
      else if(dat[nty][ntx])
    nty=ty,ntx=tx;
      if(nky<0||nkx<0||y<=nky||x<=nkx)
    nky=ky,nkx=kx;
      else if(dat[nky][nkx])
    nky=ky,nkx=kx;
      if(d[nty][ntx][nky][nkx]>cost+1){
    d[nty][ntx][nky][nkx]=cost+1;
    q.push(P2(cost+1,P1(P(nty,ntx),P(nky,nkx))));
      }
    }
  }
  return -1;
}
 
int main(){
  while(1){
    cin>>x>>y;
    if(!x&&!y)break;
    cin>>stx>>sty>>skx>>sky;
    stx--,sty--,skx--,sky--;
    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++)
    cin>>dat[i][j];
    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++)
    for(int k=0;k<y;k++)
      for(int l=0;l<x;l++)
        d[i][j][k][l]=INF;
    int ans=bfs();
    if(ans==-1)cout<<"NA"<<endl;
    else cout<<ans<<endl;
 
  }
  return 0;
}

Measured memory_bytes: 25944
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  cin >> n >> m;

  vpll v;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    v.pb(make_pair(a, b));
  }
  sort(all(v));
  rep(i, n) {
    ans += v[i].first * min(m, v[i].second);
    m = max(0LL, m - v[i].second);
  }
  cout << ans << endl;



  return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n, s = 0; cin >> n;
	vector<int> t(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		s += t[i];
	}
	int m, x, p; cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> p >> x;
		cout << s - t[p] + x << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var a = G();
		var ans = 0;
		var cnt = new Dictionary<int, int>();
		foreach (var x in a)
		{
			if (!cnt.ContainsKey(x)) cnt[x] = 1;
			else cnt[x]++;
		}
		foreach (var x in cnt.Keys)
		{
			if (cnt[x] >= x) ans += cnt[x] - x;
			else ans += cnt[x];
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 28380
using System;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            string[] nk = Console.ReadLine().Split();
            long n = long.Parse(nk[0]);
            long k = long.Parse(nk[1]);

            List<long[]> hens = new List<long[]>();
            for(long i=1;i<n;i++){
                hens.Add(new long[2]{i,n});
            }
            long count = (n-2)*(n-1) /2;
            if(k>count){
                Console.WriteLine(-1);
                return;
            }else if(k==count){
                Console.WriteLine(n-1);
                foreach(long[] hen in hens){
                    Console.WriteLine(hen[0].ToString() + " " + hen[1].ToString());
                }
                return;
            }

            for(long i=1;i<n-1;i++){
                for(long j=i+1;j<n;j++){
                    hens.Add(new long[2]{i,j});
                    count --;
                    if(count==k){
                        Console.WriteLine(hens.Count);
                        foreach(long[] hen in hens){
                            Console.WriteLine(hen[0].ToString() + " " + hen[1].ToString());
                        }
                        return;
                    }
                }
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = Console.ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return Console.ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return Console.ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = Console.ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = Console.ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 11332
// AOJ 2419 Acrophobia
// 2018.4.8 bal4u

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

#define QMAX 10000
typedef struct { char r, c, ro; short t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int r, int c, int ro, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].r = r, que[i].c = c, que[i].ro = ro, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)   ((a)>=0?(a):-(a))
#define INF  0x3030
int   W, H;
char  map[103][105];
char  roll[103][103]; int sz;
char  cost[103][103];
short dist[103][103][1<<5];
int   mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int dijkstra(int sr, int sc, int gr, int gc, int all)
{
	int i, r, c, nr, nc, ro, t, nt, x;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	enq(sr, sc, 0, 0);
	while (qsize) {
		r = que[0].r, c = que[0].c, ro = que[0].ro, t = que[0].t, deq();
		if (r == gr && c == gc && ro == all) break;
		if (dist[r][c][ro] <= t) continue;
		dist[r][c][ro] = t;
		for (i = 0; i < 4; i++) {
			nr = r + mv[i][0], nc = c + mv[i][1];
			if (map[nr][nc] == '#') continue;
			nt = t + cost[r][c];
			if (dist[nr][nc][x=(ro|roll[nr][nc])] <= nt) continue;
			enq(nr, nc, x, nt);
		}
	}
	return t;
}

int main()
{
	int r, c, d, nr, nc;
	int sr, sc, gr, gc;
	char buf[20];

	fgets(buf, 20, stdin), sscanf(buf, "%d%d", &W, &H);
	memset(map, '#', sizeof(map));
	sz = 0; for (r = 1; r <= H; r++) {
		fgets(map[r]+1, 103, stdin);
		for (c = 1; c <= W; c++) {
			if      (map[r][c] == 'S') sr = r, sc = c;
			else if (map[r][c] == 'G') gr = r, gc = c;
			else if (map[r][c] == 'M') roll[r][c] |= 1<<sz++;
		}
		map[r][c] = '#';
	}
	memset(cost, 1, sizeof(cost));
	for (r = 1; r <= H; r++) for (c = 1; c <= W; c++) if (map[r][c] == '#') {
		for (nr = r-3; nr <= r+3; nr++) for (nc = c-3; nc <= c+3; nc++) {
			if (nr < 1 || nr > H || nc < 1 || nc > W) continue;
			d = ABS(nr-r); if (d < ABS(nc-c)) d = ABS(nc-c);
			d = 4-d;
			if (d > cost[nr][nc]) cost[nr][nc] = d;
		}
	}
	printf("%d\n", dijkstra(sr, sc, gr, gc, (1<<sz)-1));
	return 0;
}


Measured memory_bytes: 2544
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
ll N, a[200000];
ll b[200000];
int main(void)
{
	cin >> N; ll cnt = 0;
	FOR(i, 0, N)cin >> a[i];
	for (int i = N-1; i >= 0; i -= 2) {
		b[cnt]=a[i];
		cnt++;
	}
	for (int i = N % 2; i < N; i += 2) {
		b[cnt] = a[i];
		cnt++;
	}
	FOR(i, 0, N) {
		cout << b[i];
		if (i != (N - 1))cout << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 5248
#include<cstdio>

using namespace std;

int main(){
    int d, n;
    scanf("%d %d", &d, &n);
    int mul1 = 1;
    int mul2 = 1;
    for(int i = 0; i < d; i++) mul1 *= 100;
    for(int i = 0; i <= d; i++) mul2 *= 100;    
    int num = 0;
    int a = 0;
    for(int i = 0; num < n; i++){
        a += mul1;
        if(a % mul1 == 0 && a % mul2 != 0){
            num++;
        }
    }
    printf("%d\n", a);
}

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

int main() {
  int A, B, num=0;
  cin >> A >> B;
  // ここにプログラムを追記
  for (int i = A; i <= B; i++) {
    int count = 0;
    string str = to_string(i);
    if (str[0] == str[4]) {
      count++;
    }
    if (str[1] == str[3]) {
      count++;
    }

    if (count == 2) {
      num++;
    }
  }

  cout << num << endl;
}

Measured memory_bytes: 384
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_6-A: Counting Sort

#include <cstdio>

static void print_ints(const int as[], const unsigned int n)
{
  auto out_sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::printf("%s%d", out_sep, as[i]);
    out_sep = " ";
  }
  std::printf("\n");
}

static const unsigned int MAX_VALUE= 10000;
static void counting_sort(int as[], int bs[], const unsigned int n)
{
  int cs[MAX_VALUE+1] ={-1, 0};
  for (auto i = 0u; i < n; ++i) {
    ++cs[as[i]];
  }
  for (auto i = 1u; i < MAX_VALUE+1; ++i) {
    cs[i] += cs[i-1];
  }
  for (auto i = 0u; i < n; ++i) {
    bs[cs[as[i]]--] = as[i];
  }
}

int main()
{
  unsigned int n;
  std::scanf("%u", &n);
  int as[n], bs[n];
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%d", &as[i]);
  }

  counting_sort(as, bs, n);
  print_ints(bs, n);
}

// eof

Measured memory_bytes: 18336
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s>>t;
	t.pop_back();
	if(s==t){
		cout <<"Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;

    s = "a" + s + "a";

    vector<pair<char,char>> v(q);
    for(auto& i : v){
        cin >> i.first >> i.second;
    }

    //vector<bool> flag(n+2, true);
    int left = 0, right = n+1;

    RREP(i, q){
        if(left >= right) break;
        if(v[i].second == 'L'){
            if(s[left + 1] == v[i].first) left++;
            if(s[right] == v[i].first) right++;
        }else{
            if(s[left] == v[i].first) left--;
            if(s[right - 1] == v[i].first) right--;
        }
    }

    cout << max(right - left - 1, 0) << endl;

    return 0;
}

Measured memory_bytes: 992
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

cal = {1: 31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}

if cal[M1] == D1:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main(){
  int N,H;
  cin >> N >> H;
  vector<pair<int,int> > wepon(N);
  int maxAttack = -1;
  for(int i = 0; i < N; i++){
    pair<int,int> input;
    scanf("%d %d",&wepon[i].second ,&wepon[i].first);
    maxAttack = max(wepon[i].second,maxAttack);
  }
  sort(wepon.begin(), wepon.end(), greater<pair<int,int> >());
  int ans = 0;

  for(int i = 0; i < N; i++){
    if(wepon[i].first > maxAttack){
      H -= wepon[i].first;
      ans ++;
      if(H <= 0) {cout << ans << endl; return 0;}
    }
  }


  if(H % maxAttack == 0) cout << ans + H / maxAttack << endl;
  else cout << ans + H / maxAttack + 1 << endl;


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int x, y;
    cin >> x >> y;

    int ans = 0;

    if(x == 1)
        ans += 300000;
    
    if(x == 2)
        ans += 200000;
    
    if(x == 3)
        ans += 100000;

    if(y == 1)
        ans += 300000;
    
    if(y == 2)
        ans += 200000;
    
    if(y == 3)
        ans += 100000;

    if(x == 1 and y == 1)
        ans += 400000;

    cout << ans << endl;
}

Measured memory_bytes: 256
from math import gcd
N,K=map(int,input().split())
A=list(map(int,input().split()))
g=A[0]
if max(A)<K:
    print('IMPOSSIBLE')
    exit()
for i in range(1,N):
    g=gcd(g,A[i])

for i in range(N):
    if (A[i]-K)%g==0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 84688
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    sort_v = sorted(v, reverse=True)
    ave = 0
    for i in range(A):
        ave += sort_v[i]
    ave = ave / A
    ans = 0
    if sort_v[0] == sort_v[A-1]:
        cnt = v.count(sort_v[A-1])
        for i in range(A, min(cnt,B)+1):
            ans += cmb(cnt,i)
    else:
        cnt = v.count(sort_v[A-1])
        ind = sort_v.index(sort_v[A-1])
        ans = cmb(cnt, A - ind)
    print(ave)
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

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 ans = 0;
  int pos = 0;
  while (pos < N) {
    int n = a[pos];
    int cur = pos;
    while (pos < N && a[pos] == n) pos++;
    int ele = pos - cur;
    if (ele < n) ans += ele;
    else ans += ele - n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pll;
const ll N=2e5+5;
struct node{
	ll u,v,w,nxt;
}edge[N*2];
ll head[N],mcnt;
ll du[N];
void add_edge(ll u,ll v,ll w){
	mcnt++;
	du[u]++;
	edge[mcnt].u=u;
	edge[mcnt].v=v;
	edge[mcnt].w=w;
	edge[mcnt].nxt=head[u];
	head[u]=mcnt;
}
ll Limit;
vector<pll>f[N],tl,tr;
void inc(ll x,pll t){
	if(f[x].size()&&f[x].back()<=t)
		return ;
	while(f[x].size()&&f[x].back().second>=t.second)
		f[x].pop_back();
	f[x].push_back(t);
}
bool dfs(ll u,ll fa){
	f[u].clear();
    if(du[u]==1){
        f[u].push_back(pll(0,0));
        return true;
    }
    ll lc,rc,distl,distr;
    bool fir=false;
    for(ll i=head[u];i;i=edge[i].nxt){
		ll v=edge[i].v,w=edge[i].w;
		if(v==fa)
			continue;
		if(!dfs(v,u))
			return false;
        if(!fir){
			fir=true;
			lc=v;
			distl=w;
        }
        else{
			rc=v;
			distr=w;
        }
    }
    tl.clear();
    tr.clear();
    ll lim2=Limit-distl-distr;
    if(lim2<0)
		return false;
    for(ll p1=0,p2=0;p2<f[rc].size();p2++){
        while(p1<f[lc].size()&&f[lc][p1].first+f[rc][p2].second>lim2)
			p1++;
        if(p1==f[lc].size())
			break;
		tl.push_back(pll(f[rc][p2].first+distr,f[lc][p1].second+distl));
    }
    for(ll p1=0,p2=0;p1<f[lc].size();p1++){
        while(p2<f[rc].size()&&f[lc][p1].second+f[rc][p2].first>lim2)
			p2++;
        if(p2==f[rc].size())
			break;
		tr.push_back(pll(f[lc][p1].first+distl,f[rc][p2].second+distr));
    }
    ll pl=0,pr=0;
    while(pl<tl.size()&&pr<tr.size()){
		if(tl[pl].first>tr[pr].first)
			inc(u,tl[pl++]);
		else
			inc(u,tr[pr++]);
    }
    while(pl<tl.size())
		inc(u,tl[pl++]);
	while(pr<tr.size())
		inc(u,tr[pr++]);
	return f[u].size()>0;
}
bool check(ll mid){
	Limit=mid;
	return dfs(1,0);
}
int main()//!ll
{
	ll n;
	scanf("%lld",&n);
	for(ll i=2;i<=n;i++){
		ll v,w;
		scanf("%lld%lld",&v,&w);
		add_edge(i,v,w);
		add_edge(v,i,w);
	}
	ll l=0,r=1e12;
	while(l<r){
		ll mid=(l+r)>>1;
        if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	printf("%lld\n",r);
}


Measured memory_bytes: 39524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            char[] ope = new char[4];

            for (int i = 0; i < 4; i++) {
                ope[i] = S[i];
            }

            var ope_list = ope.ToList();

            Console.WriteLine(ope_list.Where(x => x == '+').Count() - ope_list.Where(x => x == '-').Count());

        }

    }
}


Measured memory_bytes: 13396
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF (1LL<<40)
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
#define umap unordered_map 
#define re0 return 0
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
//typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}

template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
struct P{
    int x,y;
};

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

signed main(){
    int a,b;
    cin>>a>>b;
    cout<<max(0LL,a-2*b)<<endl;

}

/*
*/

Measured memory_bytes: 504
while input = gets
    h, w = input.chomp.split(" ").map(&:to_i)
    
    if (h == 0) && (w == 0)
        exit
    end
    
    for i in 1..h
        for j in 1..w
            print "#"
        end
        puts ""
    end
    puts ""
end


Measured memory_bytes: 6856