akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        private static Dictionary<string,int> dic = new Dictionary<string, int>();

        static void Solve()
        {
            long n = ReadAndParseLong();

            var list = new List<int>();
            if (n != 0)
            {
                while (n != 0)
                {
                    if (n % 2 != 0)
                    {
                        list.Add(1);
                        n--;
                    }
                    else
                    {
                        list.Add(0);
                    }

                    n /= -2;

                }
            }
            else
            {
                list.Add(0);
            }
            list.Reverse();
            var sb = new StringBuilder();
            foreach(var i in list)
            {
                sb.Append(i);
            }
            Console.WriteLine(sb.ToString());
        }
#region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
#endregion
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
 
const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e9 + 7;
 
ll a[MAXN];
ll b[MAXN];
ll c[MAXN];
 
int main()	
{
	faster();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		c[x - 1] = i + 1;
	}
	for (int i = 0; i < n; i++)
	{
		a[i] = 20000 * (i + 1) * 1LL;
	}
	for (int i = n - 1; i >= 0; i--)
	{
		b[i] = 20000 * (n - i - 1) + c[i] * 1LL;
	}
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < n; i++)
		cout << b[i] << " ";
	cout << endl;
}

Measured memory_bytes: 4864
n = int(input())
w = list(map(int, input().split()))

s1 = 0
s2 = sum(w)
res = sum(w)
for i in range(n):
    s1 += w[i]
    s2 -= w[i]
    res = min(res, abs(s1 - s2))
print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll int  
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define fi first
#define se second
#define mp make_pair
int main() {
ll n=5,sum=0;
ll a[n],b[n];
//map<ll,ll>m;
//vector<ll>v;
ll mood=INT_MAX;
for(ll i=0;i<n;i++)
{
  ll x;
  cin>>x;
  a[i]=x;
  if(x%10==0)
  {
    b[i]=INT_MAX;
  }
  else
  {
    b[i]=x%10;
  }
  
}
ll id=0;
for(ll i=0;i<n;i++)
{
  if(mood>b[i])
  {
    mood=b[i];
    id=i;

  }
}
sum+=a[id];
//cout<<"sum "<<id<<" "<<sum <<endl;
a[id]=0;
for(ll i=0;i<n;i++)
{
  ll q=ceil(a[i]/10.0)*10;
  //cout<<"q "<<q<<endl;
  sum+=q;
}

cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 384
count = 0 #三角形の数
right = 0 #直角三角形の数
acute = 0 #鋭角三角形の数
obtuse = 0 #鈍角三角形の数
while True:
    try:
        n = input().split()
    except EOFError: #すべて三角形だった時のため(この問いでは不要)
        print(str(count) + " " + str(right) + " " + str(acute) + " " + str(obtuse))
        break
    m = [float(i) for i in n]
    m.sort() #三角形の各辺を小さい順にｍにリスト化
    MaxArgCos = (m[0] ** 2 + m[1] ** 2 - m[2] ** 2) / (2 * m[0] * m[1]) #三角形の最大角のcosを調べる
    count += 1 #三角形の数のカウント
    if -1 < MaxArgCos < 0:
        obtuse += 1 #鈍角
    elif 0 < MaxArgCos < 1:
        acute += 1 #鋭角
    elif MaxArgCos == 0:
        right += 1 #直角
    else:
        count -= 1 #三角形ではないのでカウントを減らす
        print(str(count) + " " + str(right) + " " + str(acute) + " " + str(obtuse))
        break


Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	LL N,L;
	cin >> N >> L;
	LL a[100000];
	for(int i=0; i<N; i++) cin >> a[i];
	for(int i=1; i<N; i++){
		if(a[i-1]+a[i] >= L){
			cout << "Possible" << endl;
			for(int j=0; j<i-1; j++){
				cout << j+1 << endl;
			}
			for(int j=N-1; j>=i+1; j--){
				cout << j << endl;
			}
			cout << i << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;

	return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    int ans = 0;
    for(int i = s.length(); i > 0; i--) {
      ans += Integer.parseInt(s.substring(i-1, i));
    }

    if(ans%9 == 0) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput (string in = "s") {
  if (fopen (in.c_str(), "r"))
    freopen (in.c_str(), "r", stdin);
  else {
    cerr << "Input file not found" << endl;
  }
}
int n;
int a[Sz];   

int main()
{
  Read_rap();
  localInput();
  cin >> n;        
  n <<= 1;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort (a + 1, a + n + 1);

  int sum = 0;  
  for (int i = n-1; i >= 1; i -= 2)
    sum += a[i];

  cout << sum;

  return 0;
}










// Coded by Z..


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    if(A<B)
        printf("%d",A);
    else
        printf("%d",B);
    if(A+B-N<=0)
        printf(" 0");
    else
        printf(" %d",A+B-N);
}


Measured memory_bytes: 128
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    
    if(a * b % 2 == 0) Console.WriteLine("Even");
    else Console.WriteLine("Odd");
  }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
using namespace std;
int n,k,p;
int bit[25];
int f[1<<21][21];
char X[(1<<20)+5];
int main()
{
	scanf("%d%d",&n,&k);
	bit[0]=1;
	for(int i=1;i<=n;++i)
	{
		bit[i]=bit[i-1]<<1;
	}
	for(int len=0;len<=n;++len)
	{
		scanf("%s",X);
		for(int s=0;s<bit[len];++s) if(X[s]=='1')
		{
			f[bit[len]|s][len]=1;
		}
	}
	for(int len=n;len>=0;--len)
	{
		for(int s=0;s<bit[len];++s)
		{
			for(int i=len;i>0;--i) if(f[bit[len]|s][i])
			{
				int a=s>>i;
				for(int j=i;j>0;--j)
				{
					if(s&bit[j-1])
					{
						f[1<<(len-i+j)|(a<<j|(s&(bit[j]-1)))][j-1]+=f[bit[len]|s][i];
						break;
					}
				} 
				for(int j=i;j>0;--j)
				{
					if(~s&bit[j-1])
					{
						f[1<<(len-i+j)|(a<<j|(s&(bit[j]-1)))][j-1]+=f[bit[len]|s][i];
						break;
					}
				}
				f[1<<(len-i)|a][0]+=f[bit[len]|s][i];
			}
			if(f[bit[len]|s][0]>=k)
			{
				for(int i=len-1;~i;--i)
				{
					printf("%d",bool(s&bit[i]));
				}
				printf("\n");
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 173312
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX 50
ll num[MAX];
int main() {
  int n;
  cin >> n;
  num[0] = num[1] = 1;
  for (int i = 2; i <= n; i++) {
    num[i] = num[i-1] + num[i-2];
  }
  cout << num[n] << endl;
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
 // cin >> t;
   while (t--) {
    ll n,d,c=0;
    ll x,y;
    //vector<pair<int,int>v;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    { 
    cin>>x>>y;
   // cout<<sqrt(x*x+y*y)<<" ";
        if (sqrt(x*x+y*y)<=d)
        c++;
    }
    cout<<c<<endl;
   }
    
  return 0;
}

Measured memory_bytes: 3656
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    // kokoni kaku
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(c<=b&&c>=a?"Yes":"No")<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
const int maxn=1e5+10;
priority_queue<ll, vector<ll>, greater<ll> >Qpre;
priority_queue<ll>Qsuf;
ll pre[maxn*3];
ll suf[maxn*3];
ll a[maxn*3];
int n;
int main()
{
    scanf("%d",&n);
    ll sump=0,sumf=0;
    for(int i=1;i<=3*n;i++)
    {
        scanf("%lld",&a[i]);
        if(i<=n)sump+=a[i],Qpre.push(a[i]);

        if(i>2*n) sumf+=a[i],Qsuf.push(a[i]);
    }
    pre[n]=sump;
    for(int i=n+1;i<=2*n;i++)
    {
        if(a[i]>Qpre.top())
        {
            sump=sump+a[i]-Qpre.top();
            Qpre.pop();
            Qpre.push(a[i]);
        }
        pre[i]=sump;
    }

    suf[2*n]=sumf;
    for(int i=2*n-1;i>=n;i--)
    {
        if(Qsuf.top()>a[i+1])
        {
            sumf=sumf-Qsuf.top()+a[i+1];
            Qsuf.pop();
            Qsuf.push(a[i+1]);
        }
        suf[i]=sumf;
    }
    ll ans=pre[n]-suf[n];
    for(int i=n+1;i<=2*n;i++)
    {
        ans=max(ans,pre[i]-suf[i]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 8180
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// ここまで

fn run() {
    input! {
        n: usize,
        a: [u8; n],
    }
    let mut b = vec![0; n];
    for i in (1..n + 1).rev() {
        let mut c = a[i - 1];
        let mut j = i;
        while j <= n {
            c += b[j - 1];
            j += i;
        }
        b[i - 1] = c % 2;
    }
    let mut ans = vec![];
    for i in 0..n {
        if b[i] > 0 {
            ans.push (i + 1);
        }
    }
    println! ("{}", ans.len());
    if ans.is_empty() {
        return;
    }
    print!("{}", ans[0]);
    for x in &ans[1..] {
        print!(" {}", x);
    }
    println!();
}

fn main() {
    run();
}


Measured memory_bytes: 7164
def selection_sort(A):
    n = len(A)
    swap_cnt = 0
    for i in range(n):
        mini = i
        for j in range(i, n):
            if A[j] < A[mini]:
                mini = j
        if mini != i:
            A[i], A[mini] = A[mini], A[i]
            swap_cnt += 1
    return A, swap_cnt

n = int(input())
A = list(map(int, input().split()))
A, swap_cnt = selection_sort(A)
print(' '.join(list(map(str, A))))
print(swap_cnt)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int H,W,N,a,j,c[10000];
int main(){
    cin>>H>>W>>N;
    for(int i{1};i<=N;++i){
        cin>>a;
        while(a--)c[j++]=i;
    }
    for(int i{};i<H;++i){
        if(i%2)
            for(int j{};j<W;++j)
                cout<<c[i*W+j]<<(j!=W-1?' ':'\n');
        else
            for(int j{W-1};j>=0;--j)
                cout<<c[i*W+j]<<(j?' ':'\n');
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n, k;
  cin >> n >> k;
  vi v(n);
  rep(i, n) cin >> v[i];

  ll ans = 0;
  rep(i, n+1) {
    rep(j, n+1) {
      if (i+j > min(n, k)) continue;
      priority_queue<int, vector<int>, greater<int>> que;
      ll sum = 0;
      rep(l, i) {
        sum += v[l];
        que.push(v[l]);
      }
      rep(l, j) {
        sum += v[n-1-l];
        que.push(v[n-1-l]);
      }

      rep(l, k-i-j) {
        if (que.size() && que.top() < 0) {
          int q = que.top();
          que.pop();
          sum -= q;
        }
      }

      cmax(ans, sum);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    if(s[0]=='A'){
        int cnt1=0;
        int cwhere=1;
        for(int i=2;i<s.length()-1;i++){
            if(s[i]=='C'){
                cnt1++;
                cwhere=i;
            }
                
        }
        if(cnt1==1){
            int abc=1;
            for(int i=1;i<s.length();i++){
                if(i==cwhere)
                    continue;
                if(s[i]<'a'||s[i]>'z')
                    abc=0;
            }
            if(abc==1){
                cout<<"AC"<<endl;
                return 0;
            }
        }
    }
    cout<<"WA"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a,b,c;
int main(){
	cin >>a>>b;
	if(b<10) c = 10*a+b;
	else if(10<=b&&b<100) c = 100*a+b;
	else if(b==100) c=1000*a+b;
	int d;
	d=sqrt(c);
	if(d*d==c) cout <<"Yes"<<endl;
	else cout << "No" <<endl;
	return 0;
}

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k) {
        cout << s << endl;
    } else {
        s = s.substr(0, k);
        cout << s << "..." << endl;
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",&mark)
#define slld(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define sz(x) (int((x).size()))
#define PII pair<int,int>
#define PIL pair<int,long long>
#define PLL pair<long long,long long>
#define PIS pair<int,string>
#define MII map<int,int>
#define LL long long
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define INF 2000000000 // 2 * 10^9
#define INFLL 1000000000000000000LL  // 10^18
#define mod 1000000007

#define N 212345

LL fact[N],ifact[N];

LL power(LL a,LL b)
{
    LL rs = 1,cr = a;
    while(b)
    {
        if(b&1) rs = (rs*cr)%mod;
        cr =  (cr*cr)%mod;
        b >>= 1;
    }
    return rs;
}

LL ncr(int n,int r)
{
    LL rs = fact[n];
    rs *= ifact[r];
    rs %= mod;
    rs *= ifact[n-r];
    return rs%mod;
}

void solve()
{
    int h,w,a,b,i;
    sd(h);
    sd(w);
    sd(a);
    sd(b);
    fact[0] = 1;
    for(i=1;i<N;++i)
        fact[i] = (fact[i-1]*i)%mod;
    ifact[N-1] = power(fact[N-1],mod-2);
    for(i=N-2;i>=0;--i)
        ifact[i] = (ifact[i+1]*(i+1))%mod;
    LL rs = 0;
    //cout << ifact[0] << endl;
    for(i=0;i<(h-a);++i)
    {
        rs += (ncr(b-1+i,i)*ncr(w-1-b+h-1-i,h-1-i));
        rs %= mod;
    }
    printf("%lld\n",rs);
}

int main()
{
    int t = 1;
    //scanf("%d",&t);
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
unsigned long long n,m,k,ans;
int main()
{
	cin>>n>>m>>k;
	if (m>n)
	{
		cout<<1;
		return 0;
	}
	if (m<=k)
	{
		if (m>=n)
		{
			cout<<1;
			return 0;
		}
		cout<<-1;
		return 0;
	}
	n-=m;
	ans=n/(m-k)*2;
	if (n%(m-k)!=0) ans+=2;
	ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int Maxn = 100000;
string s;
int main()
{
    cin>>s;
    if( (s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]) )
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
xs = gets.split.map(&:to_i)
ys = xs.sort
med = {}
ys.each_with_index do |y, i|
  if i < n / 2
    med[y] = ys[n / 2]
  else
    med[y] = ys[n / 2 - 1]
  end
end
xs.each { |x| p med[x] }

Measured memory_bytes: 59584
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef priority_queue<ppr,Vppr,greater<ppr> > PprQ;
const int SIZE=5+3*1e+5;
const LL INF=1LL<<60;
const ld eps=1e-6;
const LL p=7+1e+9;
string type[2][100];
bool isWin(int mine[2],int opo[2]){
	if(min(mine[0],mine[1])>=5) return false;
	bool isLose=true;
	REP(i,2)
		REP(j,2)
			if(mine[i]<5 && opo[j]<5) {
				opo[j]+=mine[i];
				isLose&=isWin(opo,mine);
				opo[j]-=mine[i];
			}
	return !isLose;
}
int main(){
	int a,b,c,d;
	int mine[2],opo[2];
	REP(i,2)
		cin >> mine[i];
	REP(i,2) 
		cin >> opo[i];
	if(isWin(mine,opo)) cout << "ISONO" << endl;
	else cout << "NAKAJIMA" << endl;
	return 0;
}

Measured memory_bytes: 1160
S = input()

ans = 'Yes'
length  = len(S)

for i in range(0,length):
  #print(S[i])

  if (i%2==0 and S[i]=='L'):
    ans ='No'
    
  if (i%2==1 and S[i]=='R'):
    ans='No'
    
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int n; cin >>n;
  multiset<int> pros;
  rep(i, n){ int d; cin >>d; pros.insert(d); }
  string res = "YES";
  int m; cin >>m;

  auto proErase = [&](int x){
    if (pros.count(x)) pros.erase(pros.find(x));
    else res = "NO";
  };

  rep(i, m){
    int t; cin >>t;
    proErase(t);
  }
  cout <<res <<endl;
}

Measured memory_bytes: 9600
import java.util.*;
import java.io.*;
import java.lang.*;
 
public class Main {

  static class FastReader {

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() { 
      br = new BufferedReader(new InputStreamReader(System.in)); 
    } 

    String next() { 
      while (st == null || !st.hasMoreElements()) { 
        try { 
          st = new StringTokenizer(br.readLine()); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
      } 
      return st.nextToken(); 
    } 

    int nextInt() { 
      return Integer.parseInt(next()); 
    } 

    long nextLong() { 
      return Long.parseLong(next()); 
    } 

    double nextDouble() { 
      return Double.parseDouble(next()); 
    } 

    String nextLine() { 
      String str = ""; 
      try { 
        str = br.readLine(); 
      } catch (IOException e) { 
        e.printStackTrace(); 
      } 
      return str; 
    } 
  }
 
  public static void main(String args[]) throws IOException {
    // try {
    //   FileOutputStream output = new FileOutputStream("temp.out");
    //   PrintStream out = new PrintStream(output);
    //   //Diverting the output stream into file "temp.out".Comment the below line to use console
    //   System.setOut(out);
  
    //   InputStream input = new FileInputStream("temp.in");
    //   //Diverting the input stream into file "temp.in".Comment the below line to use console
    //   System.setIn(input);
  
    // } catch (FileNotFoundException e) {
    //   e.printStackTrace();
    // }
  
    FastReader sc = new FastReader();
    PrintWriter wr = new PrintWriter(System.out);
 
    // int t = 1;
    // t = sc.nextInt();    //Comment this line if there is single test case

    // while((t--) != 0) {


    // } 


    int n = sc.nextInt();

    int[] arr = new int[n];

    for(int i = 0; i < n; i++) {
      arr[i] = sc.nextInt();
    }
    long ans = 0;

    for(int i = 1; i < arr.length; i++) {
        
        if(arr[i] < arr[i-1]){
          int temp = Math.abs(arr[i] - arr[i-1]);
          arr[i] += temp;
          ans += temp;
        }
    }   

    wr.println(ans);
        
    wr.flush();
    wr.close();
  }
}

Measured memory_bytes: 54784
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
double x[10],y[10];
signed main(){
   int n;
   cin>>n;
    REP(i,n) cin>>x[i]>>y[i];
    vector<int>v;
    double bunb=1;
    for (int i = 0; i < n; i++)
    {
        v.push_back(i);
        bunb*=(i+1);
    }
    double sum=0;
    do
    {

     for (int i = 0; i < n-1; i++)
     {
         sum+=sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
     }
        
    } while (next_permutation(ALL(v)));
    printf("%.10f\n",sum/bunb);
   
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k;
	cin >> n >> k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	sort(arr,arr+n);
	int ans=1;
	int mod=1000000007;
	if((k&1) && (arr[n-1]==0)){
		cout << 0 << endl;
		return 0;
	}
	if((k&1) && (arr[n-1]<0)){
		for(int i=n-1;i>=n-k;i--){
			ans=(ans*arr[i])%mod;
			if(ans<0)	ans+=mod;
		}
		cout << ans << endl;
		return 0;
	}
	int low=0,high=n-1;
	if((k&1) && (arr[n-1]>0)){
		ans=(ans*arr[high])%mod;
		if(ans<0)	ans+=mod;
		high--;k--;
	}
	k/=2;
	for(int ii=0;ii<k;ii++){
		if(arr[low]*arr[low+1]>arr[high]*arr[high-1]){
			ans=(ans*arr[low])%mod;
			if(ans<0)	ans+=mod;
			low++;
			ans=(ans*arr[low])%mod;
			if(ans<0)	ans+=mod;
			low++;
		}
		else{
			ans=(ans*arr[high])%mod;
			if(ans<0)	ans+=mod;
			high--;
			ans=(ans*arr[high])%mod;
			if(ans<0)	ans+=mod;
			high--;
		}
	}
	if(ans<0)	ans+=mod;
	ans%=mod;
	cout << ans << endl;


	return 0;
}

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

#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++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N,X,M; cin >> N >> X >> M;

    ll a = X;

    ll cnt = 0;

    vector<ll> A(M,-1);
    vector<ll> num;
    A[a] = 0;
    num.push_back(a);
    FOR(i,1,M){
        a = a*a%M;
        if(A[a] == -1){
            A[a] = i;
            num.push_back(a);
        }else{
            cnt = A[a];
            break;
        }
    }

    int len = num.size();
    vector<ll> sum(len+1,0);
    
    REP(i,len){
        sum[i+1] += num[i] + sum[i];
    }

    
    ll loop = sum[len] - sum[cnt];

    if(N <= cnt){
        cout << sum[N] << endl;
    }else{
        cout << ((N-cnt)/(len-cnt))*loop + sum[cnt+(N-cnt)%(len-cnt)] << endl;
    }
    return 0;
}

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

int main(){
  long long int r,d,x;
  cin>>r>>d>>x;
  rep(i,10){
    x=x*r-d;
    cout<<x<<endl;}
}

Measured memory_bytes: 256
class Array
  def add_heap(x)
    self.push(x)
    i = self.length - 1
    while i != 0 and self[(i-1)/2] > self[i] do
      tmp = self[(i-1)/2]
      self[(i-1)/2] = self[i]
      self[i] = tmp
      i = (i-1)/2
    end
  end
  def delete_heap_index(i)
    self[i] = self[-1]
    self.pop
    while self[2*i+1] != nil do
      if self[2*i+2] != nil and self[2*i+2] < self[2*i+1] then
        j = 2 * i + 2
      else
        j = 2 * i + 1
      end
      if self[j] < self[i] then
        tmp = self[i]
        self[i] = self[j]
        self[j] = tmp
        i = j
      else
        break
      end
    end
  end
end

lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]
C = 10 ** 10

job = []
for i in 1..N do
  job[i-1] = lines[i][0] * C + lines[i][1]
end
job.sort!
    
t = 1
ans = 0
cand = []
while t <= M do
  loop do
    if job != [] then
      date = job[0] / C
      pay = job[0] % C
    else
      break
    end
    if date <= t then
      cand.add_heap(-pay)
      job.shift
    else
      break
    end
  end
  if cand != [] then
    ans -= cand[0]
    cand.delete_heap_index(0)
  end
  t += 1
end
puts ans

Measured memory_bytes: 23480
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  if (a * a * b / 2 < x) {
    double y = 2 * (a * a * b - x) / (a * a);
    double div = sqrt(y * y + a * a);
    double ans = acos(a / div);
    printf("%.12f\n", ans * 180 / acos(-1));
  } else {
    double y = 2 * x / (a * b);
    double div = sqrt(y * y + b * b);
    double ans = asin(b / div);
    printf("%.12f\n", ans * 180 / acos(-1));
  }
}

Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;

my $x = <STDIN>;
chomp $x;

my $n = $x;
my $b = 1;
while ($b==1)
{
	$b = 0;
    for (my $i=2; $i<$n; $i++)
    {
    	if ($n % $i == 0)
        {
	    	$b = 1;
            last;
        }
    }
    $n++;
}
$n--;
print "$n\n";

Measured memory_bytes: 768
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 500001
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);
#define pi 3.1415926535897

// class compare {
// public:
//     bool operator()(pll a, pll b) {
//         if(a.first<b.first)
//             return true;
//         else if(a.first==b.first && a.second<b.second)
//             return true;
//         return false;
//     }
// };


bool isok(ll mid, vector<ll> &T, vector<ll> &F, ll k) {

    ll op = 0;
    rep(i,T.size()) {
        if(T[i]>mid)
            op += ceil((T[i]-mid)/(double)F[i]);
    }

    if(op<=k)
        return true;
    return false;
}

int main() {

    get(n);
    get(k);

    vector<ll> A(n), F(n), T(n);
    fill_nums(A,n);
    fill_nums(F,n);
    
    sort(ALL(A));
    sort(ALL(F),greater<ll>());

    // for(auto i:A)
    //     cout<<i<<" ";
    // cout<<endl;
    // rep(i,n){
    //     cout<<A[i]*F[i]<<" ";

    // }
    // cout<<endl;
    // for(auto i:F)
    //     cout<<i<<" ";
    // cout<<endl;

    ll high = 0, low=0;
    rep(i,n) {
        T[i] = A[i]*F[i];
        high = max(A[i]*F[i],high);
    }
    // cout<<high<<endl;

    while(low<=high) {
        ll mid = low + (high-low)/2;

        if(isok(mid,T,F,k)) {
            high = mid-1;
            // cout<<mid<<endl;
        }
        else {
            low = mid+1;
        }
    }

    cout<<low<<endl;

    // for(auto i:A)
    //     cout<<i<<" ";
    // cout<<endl;
    // rep(i,n){
    //     cout<<A[i]*F[i]<<" ";

    // }
    // cout<<endl;
    // for(auto i:F)
    //     cout<<i<<" ";
    // cout<<endl;

    // priority_queue<pll, vector<pll>, compare> pq;
    // rep(i,n) {
    //     pq.push({A[i]*F[i],F[i]});
    // }

    // while(k--) {
    //     pll t = pq.top();
    //     if(t.first==0)
    //         break;
    //     pq.pop();
    //     t.first -= t.second;
    //     pq.push(t);
    // }

    // cout<<pq.top().first<<endl;

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
long long A, B, C;
int main() {
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min(A*B, min(B*C, A*C)) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        String[] list = reader.readLine().split(" ");
        int[] a = new int[N];
        for(int h=0;h<N;h++){
            a[h] =Integer.parseInt(list[h]);
        }
        int[] dp =new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(a[1]-a[0]);
        for(int i=2;i<N;i++){
            dp[i] =Math.min(dp[i-2]+Math.abs(a[i]-a[i-2]),dp[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(dp[N-1]);
    }
}



Measured memory_bytes: 35736
#include<stdio.h>

int main()
{
  char x,y;
  
  scanf("%c %c",&x,&y);
  
  if(x>y)
  {
    printf(">\n");
  }
  else if(x<y)
  {
    printf("<\n");
  }
  else
  {
    printf("=\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,j;
    string s,t;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    ll dp[n+1][m+1];

    
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            dp[i][j]=0;
            if(i==0||j==0)
            continue;
            else
            {
                if(s.at(i-1)==t.at(j-1))
                {
                   
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else
                {
                    if(dp[i-1][j]>dp[i][j-1])
                    dp[i][j]=dp[i-1][j];
                    else
                    dp[i][j]=dp[i][j-1];
                    
                }
                
            }
            
        }
        
    }
    ll len=dp[n][m];
    char str[len];
    len--;
    i=n-1;j=m-1;
    while(i>=0&&j>=0)
    {
        if(s.at(i)==t.at(j))
        {
            str[len--]=s.at(i);
            i--;
            j--;
        }
        else
        {
            if(dp[i][j+1]>dp[i+1][j])
            i--;
            else
            j--;
        }
    }
  
    for(i=0;i<dp[n][m];i++)
    cout<<str[i];
    if(dp[n][m]==0)
    cout<<"";

    
   
  
 
    return 0;
    
}
    



Measured memory_bytes: 70656
//#include "pch.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>

int main() {
	int N;
	cin >> N;
	vector<vector<P>> T(N);
	ll a, b, c;
	for (int i = 0;i < N - 1;i++) {
		cin >> a >> b >> c;
		a--;b--;
		T[a].push_back({ b,c });
		T[b].push_back({ a,c });
	}
	int Q, K, M, wz, wf;
	ll ws;
	cin >> Q >> K;
	K--;
	vector<ll> A(N, -1);
	A[K] = 0;
	queue<int> que;
	que.push(K);
	vector<P> W;
	while (!que.empty()) {
		M = que.front();
		que.pop();
		W = T[M];
		wz = W.size();
		for (int i = 0;i < wz;i++) {
			wf = W[i].first;
			if (A[wf] >= 0) continue;
			ws = W[i].second;
			A[wf] = A[M] + ws;
			que.push(wf);
		}
	}
	for (int i = 0;i < Q;i++) {
		cin >> a >> b;
		a--;b--;
		cout << A[a] + A[b] << endl;
	}
}

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

int main(void){
    vector<bool> flg(102);
    int x, n;
    cin >> x >> n;
    rep(i, n){
        int p;
        cin >> p;
        flg[p] = true;
    }
    int ans = 102, mn = abs(x - 102);
    rep(i, 102){
        if(!flg[i]){
            if(abs(x - i) < mn){
                mn = abs(x - i);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
h,w = map(int,input().split())
ma = []
for i in range(h):
    ma.append(list(input()))
directions = [[-1,0],[1,0],[0,-1],[0,1]]
ans = []

for j in range(h):
    for k in range(w):
        if ma[j][k] == '#':
            continue

        bfs = [[-1]*w for _ in range(h)]
        bfs[j][k] = 0
        que = [[j,k]]

        while len(que)>0:
            s,t = que.pop(0)
            for x,y in directions:
                if s+x < 0 or s+x>=h or t+y<0 or t+y>=w:
                    continue
                if ma[s+x][t+y] == '#':
                    continue
                if bfs[s+x][t+y] != -1:
                    continue
                bfs[s+x][t+y] = bfs[s][t] + 1
                que.append([s+x,t+y])
        
        tmp = 0
        for bf in bfs:
            for b in bf:
                if b>tmp:
                    tmp = b
        ans.append(tmp)
print(max(ans))

Measured memory_bytes: 46556
K = int(input())
a = []

def DFS(n):
    if n > 3234566667:
        return
    a.append(n)
    l = n % 10
    if l == 0:
        DFS(10 * n)
        DFS(10 * n + 1)
    elif l == 9:
        DFS(10 * n + 9)
        DFS(10 * n + 8)
    else:
        DFS(10 * n + l)
        DFS(10 * n + l + 1)
        DFS(10 * n + l - 1)

for i in range(1, 10):
    DFS(i)

a = sorted(a)
print(a[K-1])

Measured memory_bytes: 14476
def main():
  while True:
    n, m = map(int,input().split())
    if not n:
      break
    
    lst = [0] * m
  
    for i in range(n):
      lst = [i + j for i, j in zip(lst, map(int,input().split()))]
  
    lst = list(zip(lst,range(1,m + 1)))
    lst = sorted(lst,key=lambda t:-t[0])
    
    print(" ".join(map(str,[t[1] for t in lst])))
  
main()


Measured memory_bytes: 5624
N = int(input())
X = input()

def popcount(x):
    tmp = x
    count = 0
    while tmp > 0:
        if tmp & 1 == 1:
            count += 1
        tmp >>= 1
    
    return count

x = int(X, 2)
pcx = X.count("1")
pc1 = x % (pcx - 1) if pcx > 1 else 0
pc2 = x % (pcx + 1)


for i in range(N):
    if X[i] == '0':
        X_next = pc2 + pow(2,N-1-i,pcx+1)
        X_pop_next = pcx + 1
    elif X[i] == '1' and pcx - 1 != 0:
        X_next = pc1 - pow(2,N-1-i,pcx-1)
        X_pop_next = pcx - 1
    else :
        print(0)
        continue
    
        
    if X_pop_next == 0:
        print(0)
        continue
        
    X_next = X_next % X_pop_next
    ans = 1
    
    while X_next != 0:
        X_next = X_next % popcount(X_next)
        ans += 1
    
    print(ans)

Measured memory_bytes: 9472
#include <iostream>
#include <string>

using namespace std;

int main(){
  long N, x;
  long a_prev,a_cur;
  long long ans = 0;
  cin >> N >> x;
  cin >> a_prev;
  if(a_prev >= x){
    ans += a_prev - x;
    a_prev = x;
  }
  for(int i = 1; i < N; i++){
    cin >> a_cur;
    if(a_prev + a_cur > x) {
      ans +=  a_prev + a_cur - x;
      a_cur -=  a_prev + a_cur - x;
    }
    a_prev = a_cur;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int N[1],i;
	int sum = 0;
	
	//入力
	for ( i = 0;i<2;i++){
		cin >> N[i];
	}
	
	//計算
	for ( i = 0;i<2;i++){
	if(N[0] >= N[1] ){
		sum += N[0];
		N[0] -= 1;
	}else{
		sum += N[1];
		N[1] -= 1;
		}
	}
	//出力
	cout << sum << endl;

	return 0;
}

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

int main()
{
    int n,a[110],c,tmp=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=n-1;i>=0;i--)
    for(int j=1;j<=i;j++){
        if(a[j-1]>a[j]){
            c=a[j-1];
            a[j-1]=a[j];
            a[j]=c;
            tmp++;
        }
    }
    for(int i=0;i<n;i++){
            if(i<n-1)printf("%d ",a[i]);
            else printf("%d\n",a[i]);
    }
    printf("%d\n",tmp);
    return 0;
}



Measured memory_bytes: 3220
N=int(input())
for h in range(int(N/4),3501):
  for n in range(h,3501):
    a=(4*h*n-N*(n+h))
    if a!=0:
      w=N*h*n/a
      if w==int(w) and 0<w<1000000000000:
        print(h,n,int(w),sep=" ")
        exit(0)

Measured memory_bytes: 3064
//c++

#include <iostream>
#include <string>

using namespace std;

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

int main(){
	bool ans = true;
	int a = 0;
	string s;
	cin >> s;
	if(s[0] != 'A') ans = false;
	for(int i = 2;i < s.size() - 1;i++){
	if(s[i] == 'C') a++;
	else if(s[i] - 'a' < 0) ans = false;
	}
	if(s[s.size() - 1] - 'a' < 0) ans = false;
	if(s[1] - 'a' < 0) ans = false;
	if(a != 1) ans = false;
	cout << (ans ? "AC" : "WA")<< endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll MAX = 100001;
vb dp(MAX, false);

void search(ll money){
  if(dp[money]) return;
  if(money>=MAX) return;
  dp[money] = true;
  FOR(i,100,106){
    search(money+i);
  }
  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X;
  IN(X);

  search(0);

  if(dp[X]) OUT(1);
  else      OUT(0);

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
L = N - K
mod = 10 ** 9 + 7
m = mod - 2
def POW(a, b):
  bin_b = []
  while b:
    bin_b.append(b % 2)
    b >>= 1
  ret = 1
  for j in reversed(bin_b):
    ret = (ret * ret) % mod
    if j == 1:
      ret = (ret * a) % mod
  return ret
comb1 = 1
comb2 = 1
for i in range(1, K+1):
  P = POW(i, mod-2)
  comb1 = (comb1 * (L + 2 - i)) % mod
  comb1 = (comb1 * P) % mod
  print((comb1 * comb2) % mod)
  comb2 = (comb2 * (K - i)) % mod
  comb2 = (comb2 * P) % mod

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

using namespace std;

int main(void)
{
	int a;
	int b;
	cin >>a>> b;
	if (a<=b){
		if (a<b){
			cout<<"a < b"<<endl;
			}
		else {
			cout<<"a == b"<<endl;
			}
		}
	else {
		cout<<"a > b"<<endl;
		}
return 0;
}



Measured memory_bytes: 3116