akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 2500000
#define HASH_SIZE 65536

struct list {
  struct list *next;
  long num;
  long cnt;
};
// create hash
struct list *create_hashtable(int size) {
  struct list *htable = malloc(size*sizeof(struct list));
  int i;
  for(i = 0; i < size; i++) {
    htable[i].next = &htable[i];
  }
  return htable;
}

int get_key(long num) {
  return num & (HASH_SIZE-1);
}

void insert(struct list *htable, long num) {
  int key = get_key(num);
  struct list *head = &htable[key];
  struct list *elem;
  for(elem = head->next; elem != head; elem = elem->next) {
    if(elem->num == num) {
      elem->cnt++;
      return;
    }
  }

  // create
  elem = malloc(sizeof(struct list));
  elem->next = head->next;
  elem->num = num;
  elem->cnt = 1;
  head->next = elem;
  return;
}


int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  int num;

  long prev = 0;
  struct list *htable = create_hashtable(HASH_SIZE);
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d", &num);

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  int i, j;
  insert(htable, 0); // cum[0] = 0;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    long n = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
    prev = prev + n;
    insert(htable, prev);
  }

  long ans = 0;
  for(i = 0; i < HASH_SIZE; i++) {
    struct list *tmp;
    struct list *head = &htable[i];
    for(tmp = head->next; tmp != head; tmp = tmp->next) {
      ans += (tmp->cnt - 1) * tmp->cnt /2; // nC2
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 10112
import java.util.*;		
class Main{		
    public static void main(String[] args){		
        Scanner input=new Scanner(System.in);		
        int n,i,a;		
        n=input.nextInt();		
            for(i = 1; i <= n; i++){		
                a=i;		
                if((a%3) == 0)		
                    System.out.print(" "+i);		
                else{		
                for(;a >= 1;){		
                    if((a%10) == 3){		
                        System.out.print(" "+i);		
                        a=0;		
                    }		
                    a=a/10;		
                }		
                }		
            }		
            System.out.println();		
    }		
}		


Measured memory_bytes: 28876
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = sc.nextInt();
    sc.close();

    String ans = "No";
    long sum = 0;
    Arrays.sort(A);
    for (int i = A.length - 1; -1 < i; i--) {
      sum += A[i];
      if (H <= sum) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 51028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const Int MO = 1000000007;
int N;
char S[300050], T[300050];
Int dp1[300050][2], lef[300050];
Int dp2[300050][2][2];

inline void add(Int& a, Int b) {
  a += b;
  if (a >= MO) a -= MO;
}

Int solve() {
  if (T[0] == '1' && T[N - 1] == '1') {
    Int ret = 1;
    for (int i = 0; i < N; ++i) {
      if (T[i] == '?') {
        (ret *= 2) %= MO;
      }
    }
    return ret;
  }
  if (T[0] == '1') {
    reverse(T, T + N);
  }

  memset(dp1, 0, sizeof(dp1));
  memset(lef, 0, sizeof(lef));
  dp1[0][0] = 1;
  for (int i = 0; i < N; ++i) {
    if (T[i] != '1') {
      add(dp1[i + 1][0], dp1[i][0]);
      add(dp1[i + 1][0], dp1[i][1]);
    }
    if (T[i] != '0') {
      add(dp1[i + 1][1], dp1[i][0]);
      add((i % 2 == 0) ? lef[i + 1] : dp1[i + 1][1], dp1[i][1]);
    }
  }

  reverse(T, T + N);
  memset(dp2, 0, sizeof(dp2));
  dp2[0][0][0] = 1;
  for (int i = 0; i < N; ++i) {
    for (int flg = 0; flg < 2; ++flg) {
      if (T[i] != '1') {
        add(dp2[i + 1][flg][0], dp2[i][flg][0]);
        add(dp2[i + 1][flg][0], dp2[i][flg][1]);
      }
      if (T[i] != '0') {
        int nflg = flg || (i == 0);
        add(dp2[i + 1][nflg][1], dp2[i][flg][0]);
        nflg |= (i % 2 == 0);
        add(dp2[i + 1][nflg][1], dp2[i][flg][1]);
      }
    }
  }

  Int ret = lef[N];
  for (int i = 1; i < N; i += 2) {
    add(ret, lef[i] * (dp2[N - i][1][0] + dp2[N - i][1][1] + dp2[N - i][0][1]) % MO);
  }

  return ret;
}

int main() {
  scanf("%s", S);
  N = strlen(S);
  if (N == 1) {
    puts(S[0] == '0' ? "0" : "1");
    return 0;
  }

  Int res = 0;
  for (int i = 0; i < 4; ++i) {
    memcpy(T, S, sizeof(T));
    if (S[0] != '?' && S[0] != (i & 1) + '0') continue;
    if (S[N-1] != '?' && S[N-1] != (i / 2) + '0') continue;
    T[0] = (i & 1) + '0';
    T[N-1] = (i / 2) + '0';
    (res += solve()) %= MO;
  }

  printf("%lld\n", res);

  return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll A,B,C,goukei = 0;
    cin >> A >> B >> C;

    if(B >= C)
        goukei += B + C;
    else{
        goukei += 2 * B;
        C -= B;
        if(A >= C)
            goukei += C;
        else{
            goukei += A + 1;
        }
    }

    cout << goukei << endl;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int t=b/a;
	int q,h;
	long long sum=0;
	cin>>q;
	for(int i=1;i<n;i++)
	{
		cin>>h;
		if(h-q>t)
		{
			sum+=b;
		}
		else
		{
			sum+=a*(h-q);
		}
		q=h;
	}
	cout<<sum;
	
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s,d[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    in>>s;
    fr(i,7) if(s==d[i]) cout<<7-i<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}

int main() {
    int n; cin >> n;
    vector<P> red, blue;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        red.emplace_back(x, y);
    }

    rep(i, n) {
        int x, y;
        cin >> x >> y;
        blue.emplace_back(x, y);
    }

    sort(all(red));
    sort(all(blue), compare_by_second);
    reverse(all(red));

    int cnt = 0;
    rep(i, n) {
        rep(j, n) {
            if (blue[i].first > red[j].first && blue[i].second > red[j].second) {
                cnt++;
                red[j].second  = 201;
                break;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                           
#include <string>                                                                                                             
                                                                                                                              
int main(void) {                                                                                                              
  std::string RAS[2];                                                                                                         
  std::cin >> RAS[0];                                                                                                         
  std::cin >> RAS[1];                                                                                                         
  int size_ = RAS[0].size();                                                                                                  
  char tmp;                                                                                                                   
  for(int i = 0; i < size_; i++) {                                                                                            
    tmp = RAS[1][size_ - 1];                                                                                                  
    for(int j = size_ - 2; j >= 0; j--) {                                                                                     
      RAS[1][j+1] = RAS[1][j];                                                                                                
    }                                                                                                                         
    RAS[1][0] = tmp;                                                                                                          
//    std::cout << RAS[1] << std::endl;                                                                                       
    if(RAS[0] == RAS[1]) {                                                                                                    
      std::cout << "Yes" << std::endl;                                                                                        
      return 0;                                                                                                               
    }                                                                                                                         
  }                                                                                                                           
  std::cout << "No" << std::endl;                                                                                             
  return 0;                                                                                                                   
}        

Measured memory_bytes: 384
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    long takahashi = 0l;
    long aoki = 0l;
    long t_i = 0l;
    long a_i = 0l;
    long count = 1;

    for(int i=0; i<N; i++){
      t_i = Long.parseLong(scanner.next());
      a_i = Long.parseLong(scanner.next());

      if(t_i>=takahashi && a_i>=aoki){
        takahashi = t_i;
        aoki = a_i;
      }else if(t_i<takahashi && a_i>=aoki){
        if(takahashi % t_i == 0){
          count = takahashi/t_i;
          takahashi = t_i * count;
          aoki = a_i * count;
        }else{
          count = takahashi/t_i+1;
          takahashi = t_i * count;
          aoki = a_i * count;
        }
      }else if(t_i>=takahashi && a_i<aoki){
        if(aoki % a_i == 0){
          count = aoki/a_i;
          takahashi = t_i * count;
          aoki = a_i * count;
        }else{
          count = aoki/a_i+1;
          takahashi = t_i * count;
          aoki = a_i * count;
        }
      }else{
        if(takahashi%t_i==0 && aoki%a_i==0){
          count = Math.max(takahashi/t_i, aoki/a_i);
          takahashi = t_i * count;
          aoki = a_i * count;
        }else if(takahashi%t_i!=0 && aoki%a_i==0){
          count = Math.max(takahashi/t_i+1, aoki/a_i);
          takahashi = t_i * count;
          aoki = a_i * count;
        }else if(takahashi%t_i==0 && aoki%a_i!=0){
          count = Math.max(takahashi/t_i, aoki/a_i+1);
          takahashi = t_i * count;
          aoki = a_i * count;
        }else{
          count = Math.max(takahashi/t_i+1, aoki/a_i+1);
          takahashi = t_i * count;
          aoki = a_i * count;
        }
      }
    }

    System.out.println(takahashi + aoki);
  }
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b,c,cmp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       a[0]=2;
       a[1]=1;
       rrep(i,2,n+1){
           a[i]=a[i-1]+a[i-2];
       }
       Cout(a[n]);
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(i*j==n){
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        k:i32,
        x:i32
    }
    if k * 500 >= x{
        println!("Yes");
    }else{
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	long long n, m;
	cin>>n>>m;
	long long lcm = 1;
	long long v;
	vector < int > num(n);
	for (int i = 0; i < n; i++) {
		cin>>v;
		v /= 2;
		num[i] = v;
		lcm = lcm / __gcd(lcm, v) * v;
		if (lcm > m) {
			cout<<"0\n";
			return 0;
		}
	}
	
	for (int i = 0; i < n; i++)
		if ((lcm / num[i]) % 2 == 0) {
			cout<<"0\n";
			return 0;
		}
	if (m / lcm - 1 < 0) cout<<0; else cout<<((m / lcm - 1) / 2 + 1);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = -1 * (((1<<30)-1)*2+1) ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

class LazyBucket{
  public:
  vector<ll> buc,v,s;
  ll N,sqn,K;
  LazyBucket(){};
  LazyBucket(ll n){
    N = n;
    sqn = sqrt(N);
    K = (n + sqn - 1) /sqn;
    buc.assign(K,0);
    s.assign(K,0);
    v.assign(K * sqn,0);
  }
  ll getSum(int x,int y){
    ll res = 0;
    for (int k = 0; k < K; ++k) {
      int l = k * sqn, r = (k + 1) * sqn;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        res += s[k] + buc[k] * sqn;
      } else {
        lazyupdate(k);
        for (int i = max(x, l); i < min(y, r); ++i) {
          res += v[i] + buc[k];
        }
      }
    }
    return res;
  }
  void lazyupdate(int k){
    if(k >= K) return ;
    if(buc[k] != 0){
      for(int i = k * sqn; i < (k+1) * sqn;++i){
        v[i] += buc[k];
        s[k] += buc[k];
      }
    }
    buc[k] = 0;
  }
  void add(ll x,ll y,ll n){
    for (ll k = 0; k < K; ++k) {
      ll l = k * sqn, r = (k + 1) * sqn;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        buc[k] += n;
      }
      else {
        lazyupdate(k);
        for (int i = max(x, l); i < min(y, r); ++i) {
          v[i] += n;
          s[k] += n;
        }
      }
    }
  }
  void Debug(){
    cout << "sqn " << sqn << endl;
    for(int i = 0; i < N;++i){
      cout << buc[i/sqn] << ' ';
    }
    cout << endl;
    for(int i = 0; i < N;++i){
      cout << s[i/sqn] << ' ';
    }
    cout << endl;
    for(int i = 0; i < N;++i){
      cout << v[i] << ' ';
    }
    cout << endl;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, q,s,t,x,a;
  cin >> n >> q;
  LazyBucket buc(n+1);
  rep(i,q){
    /* buc.Debug(); */
    cin >> a;
    if(a){
      cin >> s >> t;
      cout << buc.getSum(s-1,t) << endl;
    }
    else{
      cin >> s >> t >> x;
      buc.add(s-1,t,x);
    }
  }
  return 0;
}

Measured memory_bytes: 3528
// https://atcoder.jp/contests/abc053/tasks/abc053_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC\n";
    } else {
        cout << "ARC\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	string s;
	cin >> s;
	long long count = 0;
	int l = 0, r = n - 1;
	while(l < r) {
		if(s[l] != 'W') {
			l++;
			continue;
		}
		if(s[r] != 'R') {
			r--;
			continue;
		}
		if(s[l] == 'W' && s[r] == 'R') {
			swap(s[l], s[r]);
			l++;
			r--;
			count++;
		} 	
	}
	cout << count << "\n";
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		FastScanner FastScanner = new FastScanner();
		String s = FastScanner.next();
		if (s.substring(2, 3).equals(s.substring(3, 4)) && s.substring(4, 5).equals(s.substring(5, 6))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int xmax = w;
  int xmin = 0;
  int ymax = h;
  int ymin = 0;
  for(int i=0;i<n;i++){
    int x = 0;
    int y = 0;
    int a = 0;
  cin >> x >> y >> a;
  if(a == 1){
    if(xmin < x){
      xmin = x;
    }
  }else if(a == 2){
    if(xmax > x){
      xmax = x;
    }
  }else if(a == 3){ 
    if(ymin < y){
      ymin = y;
    }
  }else if(a == 4){
    if(ymax > y){
      ymax = y;
    }
  }
  }
  
  if((xmin <= xmax) && (ymin <= ymax)){
    cout << (xmax - xmin)*(ymax -ymin) << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   printf("%ld\n", n/3);
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2])
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int, int > Pi;
 
const int INF = 1 << 30;

int N;
Pi Bugs[300000];


int Justin()
{
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  int64 sum = 0, ret = 0;
  for(int i = 0; i < N; i++){
    que.push( make_pair( Bugs[i].second, Bugs[i].first));
    sum += Bugs[i].first;
    while(!que.empty() && (int64)que.top().first * que.size() < sum){
      sum -= que.top().second;
      que.pop();
    }
    ret = max< int >( ret, que.size());
  }
  return(ret);
}

int main()
{
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d %d", &Bugs[i].first, &Bugs[i].second);
  }
  sort( Bugs, Bugs + N);
  cout << Justin() << endl;
  return(0);
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007

int main() {
    int n, h, d; cin >> n >> h >> d;
    vector<long long> fact(n+1, 1); long long sum = 0;
    for (long long i = 0; i < n; i++) {
        fact[i+1] = fact[i] * (i+1) % mod;
        sum = (sum + fact[i+1]) % mod;
    }
    vector<long long> dp(h+1, 0), dp_sum(h+1, 0);
    dp[0] = fact[n];
    for (int i = 1; i <= h; i++) {
        dp_sum[i] = (dp_sum[i-1] + dp[i-1]) % mod;
        dp[i] = (dp_sum[i] + (mod - dp_sum[max(0, i-d)])) % mod;
        if (i != h) dp[i] = dp[i] * sum % mod; 
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 23680
n,k=map(int,input().split())
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
m=list(d.values())
m.sort()
a=len(m)-k
ans=0
for i in m:
  if a<=0:
    break
  a-=1
  ans+=i
print(ans)


Measured memory_bytes: 41120
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    map<int, int>m;
    int tmp;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        m[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(m[a[i]] != a[i] && m[a[i]] > 0) {
            m[a[i]]--;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>

#define MAX 100
#define INFTY 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void difkstra()
{
  int i, u, v, minv;
  int d[MAX], color[MAX];

  for( i=0; i<n; i++ )
    {
      d[i] = INFTY;
      color[i] = WHITE;
    }

  d[0] = 0;                  /*スタート地点を０に設定する*/
  color[0] = GRAY;               
  while(1)
    {
      minv = INFTY;          
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )   
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( minv == INFTY ) break;
      color[u] = BLACK;
      for( v=0; v<n; v++ )
	{
	  if( color[v] != BLACK && M[u][v] != INFTY )
	    {
	      if( d[v] > d[u] + M[u][v] )
		{
		  d[v] = d[u] + M[u][v];
		  color[v] = GRAY;
		}
	    }
	}
    }

  for( i=0; i<n; i++ )
    {
      printf("%d %d\n", i, d[i]);
    }
  
}


int main()
{
  int i, j,u, k, v, c;
  
  scanf("%d", &n);

  for( i=0; i<n; i++ )
    {
      for( j=0; j<n; j++ )
	{
	  M[i][j] = INFTY;
	}
    }
  
  for( i=0; i<n; i++ )
    {
      scanf("%d%d", &u, &k);

      for( j=0; j<k; j++ )
	{
	  scanf("%d%d", &v, &c);
	  M[u][v] = c;
	}
    }

  difkstra();

  return 0;
}
      



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    string S; cin >> S;
    string T = "keyence";
    bool ans = false;
    REP(i, S.size()) REP(j, S.size()){
        if(i + j <= S.size() && S.substr(0, i) + S.substr(S.size() - j, j) == T) ans = true;
    }
    ANS(ans);
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
	typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)

class Primes {
	private:
		vector<int> Prime_Number;
		vector<bool> is_prime_;
	public:
		Primes(int N) {
			is_prime_.resize(N + 1, true);
			is_prime_[0] = is_prime_[1] = false;
			for (int i = 0; i < N + 1; i++) {
				if (is_prime_[i]) {
					Prime_Number.push_back(i);
					for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
				}
			}
		}
		int operator[](int i) { return Prime_Number[i]; }
		int size() { return Prime_Number.size(); }
		int back() { return Prime_Number.back(); }
		bool isPrime(int q) { return is_prime_[q]; }
	};

class Divisor {
	private:
		vector<ll> F;
		vector<pair<ll, ll>> pfactorize;
	public:
		Divisor(ll N) {
			for (ll i = 1; i * i <= N; i++) {
				if (N % i == 0) {
					F.push_back(i);
					if (i * i != N) F.push_back(N / i);
				}
			}
			sort(begin(F), end(F));
			Primes p((ll)sqrt(N) + 1);
			for (int i = 0; i < p.size(); i++) {
				pfactorize.emplace_back(p[i], 0);
				while (N % p[i] == 0) {
					N /= p[i];
					pfactorize.back().second++;
				}
				if (pfactorize.back().second == 0) pfactorize.pop_back();
			}
			if (N > 1) pfactorize.emplace_back(N, 1);
		}
		int size() { return F.size(); }
		const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
	};

int main(void)
{
	ll a, b;
	cin >> a >> b;
	Divisor d(a);
	ll sum = 1;
	for (auto e : d.pfac()) {
		if (b % e.first == 0) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W ;
  vector<string>str(H);
  for (int i = 0;i<H;i++){
    cin >> str.at(i);
  }
  string a="#";
  for (int k = 0; k<W+1;k++){
    a += '#';
  }
  
      
  cout << a <<endl;
  for (int j= 0;j<H;j++){
    cout <<'#'<<str.at(j)<<'#'<<endl;
  }
  cout << a << endl;
}

  	
    
    
  
        
      

    
  
    
      
    
      

    
  
  
    

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
 
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	
    	int n = 999;
    	int[] f = new int[n];
    	f[0] = 1;
    	
    	for(int i = 1; i < n; i++){
    		f[i] = f[i-1] + (i+1);
    	}
    	
    	int d = b - a;
    	int ans = 0;
    	for(int i = 2; i < n; i++){
    		if(f[i] - f[i-1] == d){
    			ans = f[i] - b;
    			break;
    		}
    	}
    	
    	System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int N, T; cin >> N >> T;

    int minCost = INF;
    REP(i, N) {
        int c, t; cin >> c >> t;
        if(t<=T) {
            if(c < minCost) { 
                minCost = c;
            }
        }
    }

    if (minCost == INF) {
        cout << "TLE" << endl;
    } else {
        cout << minCost << endl;
    }

    
    return 0;
}

Measured memory_bytes: 888
N, M = map(int, input().split())
A = []
for _ in range(N):
    s = list(map(int, input().split()))
    k = s[0]
    A.append(s[1:])

foods = [0] * M
for row in A:
    for a in row:
        foods[a-1] += 1
count = 0
for f in foods:
    if f == N:
        count += 1
print(count)



Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	int n;
	cin >> n;
	vector<pair<int, int>> xy;
	int x, y;
	cin >> x >> y;
	xy.emplace_back(x, y);
	double ans = 0;
	int n_ = 1;
	for (int i = 1; i < n; i++) {
		n_ *= (i + 1);
	}
	for (int i = 1; i < n; i ++) {
		cin >> x >> y;
		for (int j = 0; j < xy.size(); j++) {
			ans += 2 * n_ / n * pow(pow(x - xy[j].first, 2) + pow(y - xy[j].second, 2), 0.5);
		}
		xy.emplace_back(x, y);
	}
	cout << ans / n_ << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

Vl A(45), B(45);

int main() {
    ll a, b; cin >> a >> b;
    b++;
    ll r = 2, l = 1;
    Rep(i, 0, 40){
        A[i]+=(a/r)*l;
        if(a%r > l) A[i]+=a%r-l;
        r*=2; l *= 2;
    }
    // print(A);
    r = 2, l = 1;
    Rep(i, 0, 40){
        B[i]+=(b/r)*l;
        if(b%r > l) A[i]+=b%r-l;
        r*=2; l *= 2;
    }
    // print(B);
    Rep(i, 0, 40){
        B[i]-=A[i];
        B[i]%=2;
    }
    ll u = 1;
    ll ans = 0;
    Rep(i, 0, 40){
        if(B[i]){
            ans += u;
        }
        u *= 2;
    }

    // for(int i = 40; i >= 0; i--){
    //     cout << B[i];
    // }
    // coel;
    
    co(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int primes[100];

int get_primes(int n) {
    int ret = 0;
    for (int i = 2; i <= n; i++) {
        bool flag = true;
        for (int j = 2; j <= i; j++) {
            if (i % j == 0 && i != j) {
                flag = false;
                break;
            }
        }
        if (flag) {
            primes[ret++] = i;
        }
    }
    return ret;
}

int main() {
    int n, cnt, ans = 0;
    int exps[100] = {0};

    cin >> n;

    cnt = get_primes(n);

    for (int i = 2; i <= n; i++) {
        int k = i;
        for (int j = 0; j < cnt; j++) {
            while (k % primes[j] == 0) {
                exps[j]++;
                k /= primes[j];
            }
        }
    }

    int dp[100][76] = {0};

    dp[0][1] = 1;

    for (int i = 0; i < cnt; i++) {
        for (int j = 0; j <= 75; j++) {
            for (int k = 0; k <= exps[i]; k++) {
                if (j * (k + 1) > 75) { break; }
                dp[i + 1][j * (k + 1)] += dp[i][j];
            }
        }
    }

	cout << dp[cnt][75] << endl;

    return 0;
}

Measured memory_bytes: 256
function main()
    N = parse(Int, readline())
    A = map(x -> parse(Int, x), split(readline()))

    res = 0

    while true
        exist_odd = false
        for i = 1:N
            if A[i] % 2 != 0
                exist_odd = true
            end
        end

        if exist_odd
            break
        end

        for i = 1:N 
            A[i] /= 2
        end

        res += 1
    end

    println(res)
end

main()

Measured memory_bytes: 111576
import sys


def main():
    n, m = map(int, sys.stdin.readline().split(" "))
    mem = dict()
    ac_count = 0
    wrong_count = 0
    for _ in range(m):
        t, result = sys.stdin.readline().strip().split(" ")
        test_no = int(t)
        if test_no > n:
            continue
        if test_no in mem:
            if mem[test_no] > 0:
                if mem[test_no] == -1:
                    continue
                if result == "WA":
                    mem[test_no] += 1
                else:
                    ac_count += 1
                    wrong_count += mem[test_no]
                    mem[test_no] = -1
        else:
            mem[test_no] = result == "AC"
            if result == "WA":
                mem[test_no] = 1
            else:
                ac_count += 1
                mem[test_no] = 0
    print("%d %d" % (ac_count, wrong_count))


if __name__ == '__main__':
    main()


Measured memory_bytes: 15132
n = map(int, raw_input().split())
s = raw_input()
x = 0
max = 0
i=0
while i<len(s):
    if s[i] == 'I':
        x = x + 1
        if max < x:
            max = x
    elif s[i] == 'D':
        x = x - 1

    i=i+1
print max

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

int main()
{
    int n,i;
    cin>>n;
    double a[n],sum;
    for(i=0;i<n;i++)
    {
        cin>>a[i];

    }
    sort(a,a+n);
    sum=a[0];
    for(i=1;i<n;i++)
    {
        sum=(sum+(double)a[i])/2;
    }
    cout<<sum;
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, t;
	cin >> a >> b;
	b--; a--;
	t = (b / a) + (b % a == 0 ? 0 : 1);
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/
int main(){
    int a; cin >> a;
    cout << a + a * a + a * a * a << endl;
} 

Measured memory_bytes: 3592
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n, a[100005];

int f0() {
	if (a[1] == a[n] && a[1] == n - 1) return 1;
	return 0;
}

int f2() {
	if (a[1] == a[n]) {
		return a[1] * 2 <= n;
	}
	return 0;
}

int f1() {
	if (a[1] != a[n] - 1) return 0;
	int cnt1 = 0;
	for (int i = 1; i <= n; i++) if (a[1] == a[i]) cnt1++;
	int cnt2 = n - cnt1;
	if (2 * (a[1] - cnt1 + 1) > cnt2) return 0;
	if (2 * (a[1] - cnt1 + 1) <= 0) return 0;
	return 1;
}

int f3() {
	if (a[1] == a[n] && a[1] == 1) return 1;
	return 0;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + 1 + n);
	if (f3() || f0() || f1() || f2()) printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;

#define MOD 1000000007

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

    int n;
    cin >> n;

    if (n%1000 == 0) cout << 0 << endl;
    else cout << (1000-(n%1000)) << endl;

    return 0;
}


Measured memory_bytes: 3180
# -*- coding: utf-8 -*-

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]

    def same(self, x, y):
        return self.root(x)==self.root(y)

    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x==y:
            return

        if self.par[x]>self.par[y]:
            x,y = y,x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self,x):
        return -self.par[self.root(x)]

n,m = map(int, input().split())
pl = list(map(int, input().split()))
uf = UnionFind(n+1)
for _ in range(m):
    x,y = map(int, input().split())
    uf.unite(x,y)

res = 0
for i in range(n):
    if uf.same(i+1, pl[i]):
        res += 1

print(res)


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

ll s1,s2,s,t1,t2,t;

void xgcd(ll x,ll y) {
    if(x%y==0)return;
    ll q=x/y;
    s=s2-q*s1;
    t=t2-q*t1;
    s2=s1,t2=t1,s1=s,t1=t;
    xgcd(y,x%y);
}

int main() {
    ll a,b;
    //while(1) {
    cin >> a >> b;
    s1=0;
    s2=1;
    t1=1;
    t2=0;
    xgcd(a,b);
    cout << s1 << " " << t1 << endl;
    //}
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
 
int main(){
  int a;
  char *blank;
  int b;

  scanf("%d", &a);
  scanf("%c",  blank);
  scanf("%d", &b);
 
  printf("%d ",a*b);
  printf("%d\n",2*a+2*b);
 
  return 0;
}


Measured memory_bytes: 2660
#include<bits/stdc++.h>
using namespace std;
int main () {
  vector<int> data(3);
  for (int i = 0; i < 3; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  cout << data.at(2) * 10 + data.at(1) + data.at(0) << endl;
  return 0;
}


Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(X);
    cout<<((X>=30)?"Yes":"No")<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3816