akhauriyash/Code-Regression huggingface dataset:
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link relink
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string &fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 5000;

int n, k;
vector<int> a;
bitset<N> t, t2;

int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n >> k;
  int ans = n;
  LL suma = 0;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    suma += x;
    if (x >= k) {
      --ans;
    } else {
      a.pb(x);
    }
  }

  if (suma < k) {
    cout << n << endl;
    return 0;
  } else if (suma == k) {
    cout << 0 << endl;
    return 0;
  }
  n = (int)a.size();

  t.set(0);
  for (int i = 0; i < n; i++) {
    if (i) t = (t << a[i - 1]) | t;
    t2 = t;
    bool f = 0;
    for (int j = i + 1; j < n; j++) {
      t2 = (t2 << a[j]) | t2;
      if (~j & 31) {
        for (register int l = k - a[i]; l < k; ++l) {
          if (t2.test(l)) {
            f = 1;
            break;
          }
        }
        if (f) break;
      }
    }
    for (register int j = k - a[i]; j < k; ++j) {
      if (t2.test(j)) {
        f = 1;
        break;
      }
    }
    ans -= f;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> void generatePrimes(T n);
template <class T> void factorize(T n);

vector<ll> primes;
int donePrime = 1;
ll ans = 1;


int main()
{
	ll a, b; cin >> a >> b;
	ll g = gcd(a, b);

	if (g == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	factorize(g);

	cout << ans << endl;
}

template <class T> void factorize(T n)
{
	if (n < 2)
		return;

	T rt = (T)ceil(sqrt(n));

	if (donePrime < rt)
		generatePrimes(rt);

	for (T d : primes)
	{
		if (n < d) break;

		if (!(n % d))
		{
			++ans;
			while (!(n % d))
				n /= d;
		}
	}

	if (n != 1)
		++ans;
}

template <class T> void generatePrimes(T n)
{
	if (n <= donePrime)
		return;
	if (primes.empty()) primes.push_back(2);
	if (primes.back() == 2 && n > 2) primes.push_back(3);

	bool isPrime;

	for (T k = primes.back() + 2; k <= n; k += 2)
	{
		if (!(k % 3)) continue;
		isPrime = true;
		T lim = (T)ceil(sqrt(k));

		for (T p : primes)
		{
			if (p > lim) break;
			if (!(k % p))
			{
				isPrime = false; break;
			}
		}

		if (isPrime)
			primes.push_back(k);
	}

	donePrime = n;
}

Measured memory_bytes: 1400
n = int(input())
train = [list(map(int, input().split())) for i in range(n-1)]

for i in range(n-1):
    ans = 0
    for j in range(i,n-1):
        if ans <=train[j][1]:
            ans = train[j][1]+ train[j][0]
        else:
            if ans%train[j][2]==0:
                ans += train[j][0]
            else:
                ans = train[j][0] + (ans//train[j][2]+1)*train[j][2]
    print(ans)

print(0)

Measured memory_bytes: 42220
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;

  cin >> n;

  if (n % 2) {
    cout << n * 2 << endl;
  } else {
    cout << n << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long n,m;
    cin >> n >> m;
    long long ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= (m - i);
        ans %= 1000000007;
    }
    long long p = 1;
    long long q = 0;
    for (int i = 0; i < n; i++) {
        long long qq = q;
        q = (qq+p) * (n - i - 1);
        p *= (m - n);
        p += qq * (m - n + 1);
        p %= 1000000007;
        q %= 1000000007;
    }
    cout << ans*p%1000000007 << endl;
}

Measured memory_bytes: 3620
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
#define ull unsigned long long  
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
//ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	ll s,w;
	cin>>s>>w;
	 if(s<=w)
 	cout<<"unsafe";
 	else cout<<"safe";
 	
}

Measured memory_bytes: 3636
n=int(input())
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n - 99 + 9)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n - 9999 + 909)
elif n < 1000000:
    print(90909)


Measured memory_bytes: 38480
W, H, x, y = map(int, input().split())

max = W*H/2.0

a = W/2
b = H/2

gap = 0.000000001
flag = 0

if(abs(x-a) < gap and abs(y-b) < gap):
    flag = 1

print('{:.6f} {}'.format(max, flag))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	int yt=y2-y1,xt=x2-x1;
	for(int i=1;i<=yt;i++)cout<<"U";
	for(int i=1;i<=xt;i++)cout<<"R";
	for(int i=1;i<=yt;i++)cout<<"D";
	for(int i=1;i<=xt;i++)cout<<"L";
	cout<<"L";
	for(int i=1;i<=yt+1;i++)cout<<"U";
	for(int i=1;i<=xt+1;i++)cout<<"R";
	cout<<"DR";
        for(int i=1;i<=yt+1;i++)cout<<"D";
        for(int i=1;i<=xt+1;i++)cout<<"L";
	cout<<"U\n";
	return 0;
}

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

int main() {
	int N;
  	cin >> N;
  
  	vector<int> vec(N);
  
  	for(int i = 0; i < N; i++) {
    	cin >> vec.at(i);
    }
  
  	sort(vec.begin(),vec.end());
  	int length_sum = 0;
  
  	for(int i = 0; i < N - 1; i++) {
    	length_sum += vec.at(i);
    }
  
  	if(length_sum > vec.at(N - 1)) {
    	cout << "Yes" << endl;
    }else {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll d[100010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++)cin>>d[i];
    sort(d,d+N);
    cout<<d[N/2]-d[N/2-1]<<endl;
    return 0;
}

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

using namespace std;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int X, Y;
  cin >> X >> Y;
  UnionFind uf(13);
  uf.unite(1, 3);
  uf.unite(3, 5);
  uf.unite(5, 7);
  uf.unite(7, 8);
  uf.unite(8, 10);
  uf.unite(10, 12);
  uf.unite(4, 6);
  uf.unite(6, 9);
  uf.unite(9, 11);
  puts(uf.find(X) == uf.find(Y) ? "Yes" : "No");
}




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

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


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;}

int main()
{   
    int h,w; cin >> h >> w;
    vector<vector<char> > s(h+2,vector<char>(w+2));
    rep1(i,h+1)rep1(j,w+1)cin >> s[i][j];

    rep1(i,h+1){
        rep1(j,w+1){
            if(s[i][j] == '#')
                cout << '#';
            else{
                int res = 0;
                for(int k=i-1;k<i+2;k++){
                    for(int p=j-1;p<j+2;p++){
                        if(s[k][p] == '#') res++;
                    }
                }
                cout << res;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b; scanf("%d%d", &a, &b);
if (a==b) printf("Draw\n");
else if (a==1) printf("Alice\n");
else if (b==1) printf("Bob\n");
else if (a>b) printf("Alice\n");
else printf("Bob\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N, A, B;
	cin >> N >> A >> B;

	if (B - A & 1) cout << "Borys";
	else cout << "Alice";

	return 0;
}

Measured memory_bytes: 256
/*
Please Chant The Holy Name Of Lord Krisna(The Supreme Personality Of Godhead)

      "Hare Krisna Hare Krisna Krisna Krisna Hare Hare
       Hare Rama Hare Rama Rama Rama Hare Hare ......."

Surrender yourself to the Lotus Feet of Krisna, serve devotees and Srila Prabhupada
*/

//13-9-20
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb emplace_back
#define sz(s) (int)s.size()
#define all(v)                            v.begin(),v.end()
#define fr(i,n)                           for(int i=0;i<n;i++)
#define fr1(i,n)                          for(int i=1;i<=n;i++)
#define fro(i,a,b)                        for(int i=a;i<=b;i++)
#define d(a)                              cout << #a << " : " << a << " ";
#define dl(a)                             cout<< #a <<" : " << a << endl;
#define print(v)  for(auto x : v)         {cout<<x<<" ";   }  cout<<endl;
#define PRINT(v)  for(auto x : v)         {cout<<x.first<<" "<<x.second<<endl;}
#define TEST                              int tc;cin>>tc; while(tc--)

using namespace std;

const int N   = 2e5 + 7;
const int MOD = 1e9 + 7;
int arr[N];
int n,m,k,x,y,i,j;

void solve()
{
    // Can you solve it by brute force?
    // kkp
    // Are you sure you want to code so soon?? -_-
    // Simplify your code a little more. :)

    int x;
    cin>>x;

    if(x==0)
        cout<<1<<endl;
    else
        cout<<0<<endl;

}

int32_t main()
{
    //IOS;

    //TEST
    solve();

    return 0;
}



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

int main()
{

    string m,n;
    cin>>m>>n;
    int i,ansi;bool fd=0;
    for(i=0;i<=(int)(m.size()-n.size());i++)
    { int ans=0;
        for(int j=0;j<(int)n.size();j++)
        {
            if(m[j+i]==n[j] || m[j+i]=='?')
            {
                ans++;
            }

        }
        if(ans==(int)n.size()){
            fd=1;
            ansi=i;
        }

    }
    if(fd){
        string ap="";

        for(int j=0;j<m.size();j++) {
            if (m[j] == '?')
                m[j] = 'a';

        }

     for(int j=0;j<ansi;j++)
         cout<<m[j];
        for(int j=0;j<n.size();j++)
          cout<<n[j];


for(int e=ansi+n.size();e<m.size();e++)
  cout<<m[e];
        cout<<endl;

    }else{
        cout<<"UNRESTORABLE\n";
    }

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int len = s.size();

    long long ans = stoll(s);

    for (int i = 1; i < 1 << len - 1; i++)
    {
        bitset<9> bit(i);
        long long num = s[0] - '0';
        for (int j = 0; j < len - 1; j++)
        {
            if(bit[j])
            {
                ans += num;
                num = s[j + 1] - '0';
            }
            else
            {
                num *= 10;
                num += s[j + 1] - '0';
            }
        }
        ans += num;
    }
    
    cout << ans;
}

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

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

  string s;
  cin >> s;

  unordered_set<char> appeared;
  string ans = "yes";
  for (char &c : s) {
    if (appeared.find(c) != appeared.end()) {
      ans = "no";
      break;      
    }
    appeared.insert(c);
  }
  cout << ans << '\n';
  return 0;

}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,m;
	cin>>n>>m;

	int h[n+1];
	vector<bool> f(n+1, 1);
	for(int i=1;i<=n;i++) {
		cin>>h[i];
	}	
	int u,v;
	for(int i=0;i<m;i++) {
		cin>>u>>v;
		if(h[u]>=h[v]) {
			f[v]=0;
		}
		if(h[u]<=h[v]) {
			f[u]=0;
		}
	}

	int ans =0;
	for(int i=1;i<=n;i++) {
		if(f[i])
			ans++;
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 4416
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let s = get_string_input();
    println!("{}", &s[0..3]);
}

#[allow(dead_code)]
fn get_digit(value: i64) -> i64 {
    let mut digit = 0i64;
    let mut value = value;
    while value != 0 {
        value /= 10;
        digit += 1;
    }
    digit
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



Measured memory_bytes: 2112
function main(arg) {
	arg = arg.trim().split(/\n/);
  	var st = arg[0].split(' '), a = arg[1].split(' '),
        ms = st[0], ara = st[1], at = 0, result = 0;
  	a = a.map(str => parseInt(str, 10));
	a = a.forEach(function(ele) {
    	 at += ele
    });
  	result = ms - at;
  	var out = result <=  0 ? 'Yes' : 'No';
  	
  console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  int ans=0;
  int b[m];
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    int temp=c;
    for(int j=0;j<m;j++){
      int num;
      cin>>num;
      temp+=num*b[j];
    }
    if(temp>0)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
 
int main(){
    std::stack<u_int> train;
    u_int num;
    while(std::cin >> num){
        if(num == 0){
            std::cout << train.top() << std::endl;
            train.pop();
        }
        else {
            train.push(num);
        }
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int c = 0;
 for(int i = 0;i < 4;i++){
  if( s[i] =='+') c++;
   else if (s[i] == '-') c--;
}
 cout << c << endl;
}

  




Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
const int N = 2e5 + 5;
int n, m, cnt[N][2];
char str[N];
bool tag[N], del[N];
vector<int> G[N];
queue<int> Q;
int main() {
	scanf("%d%d%s", &n, &m, str + 1);
	for (int i = 1; i <= n; ++i)
		tag[i] = (str[i] == 'A') ? 1 : 0;
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i)
		for (int to : G[i])
			++cnt[i][tag[to]];
	while (Q.size())
		Q.pop();
	for (int i = 1; i <= n; ++i)
		if (!cnt[i][0] || !cnt[i][1])
			Q.push(i), del[i] = 1;
	while (Q.size()) {
		int u = Q.front();
		Q.pop();
		for (int to : G[u]) {
			if (del[to])
				continue ;
			--cnt[to][tag[u]];
			if (!cnt[to][0] || !cnt[to][1]) {
				Q.push(to);
				del[to] = 1;
			}
		}
	}
	bool ans = 0;
	for (int i = 1; i <= n; ++i)
		ans |= !del[i];
	if (ans)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<int> G[100010];

int depth[100010];
int dfs(int s, int p = -1) {
    if(depth[s] >= 0) return depth[s];
    vector<int> v;
    for(auto to: G[s]) {
        if(to == p) continue;
        v.push_back(dfs(to, s) + 1);
    }
    sort(v.begin(), v.end(), greater<int>());
    int k = 0;
    rep(i, v.size()) {
        k = max(k, v[i] + i);
    }
    return depth[s] = k;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    rep(i, n - 1) {
        int a; cin >> a;
        a--;
        G[i + 1].push_back(a);
        G[a].push_back(i + 1);
    }
    rep(i, n) depth[i] = -1;
    cout << dfs(0) << endl;

    return 0;
}


Measured memory_bytes: 15488
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;


const double EPS = 1e-9;

static bool uruu[3000];

int main(){
	for(int i = 0; i < 3000; i+=4){
		uruu[i] = true;
	}
	for(int i = 0; i < 3000; i+=100){
		uruu[i] = false;
	}
	for(int i = 0; i < 3000; i+=400){
		uruu[i] = true;
	}
	

	int a, b;
	bool f = true;
	while(cin >> a >> b, b){
		if(!f){
			cout << endl;
		}
		f = false;
		bool na = true;
		for(int i = a; i <= b; i++){
			if(uruu[i]){
				cout << i << endl;
				na = false;
			}
		}
		if(na){
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	long l = Long.parseLong(sc.next());
	long r = Long.parseLong(sc.next());
	long min = (l*r)%2019;
	if((r - l) >= 2018){
		System.out.println(0);
	}else{
		for(long i = l; i < r; i++){
			for(long j = i+1; j < r+1; j++){
				if((j*i)%2019 < min){
					min = ((j*i)%2019);
				}
			}
		}
	System.out.println(min);
	}
}
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    n--;
    vector<ll> v;
    for(i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            v.push_back(i);
            if(n / i != i) {
                v.push_back(n / i);
            }
        }
    }
    ll ret = v.size() - 1;
    n++;
    for(i = 1; i * i <= n; i++) {
        if(n % i == 0 && i != 1) {
            m = n;
            while(m % i == 0) {
                m /= i;
            }
            if(m % i == 1) ret++;
            if(n / i != i) {
                k = n / i;
                m = n;
                while(m % k == 0) {
                    m /= k;
                }
                if(m % k == 1) ret++;
            }
        }
    }
    cout << ret+1 << endl;
    return 0;
}

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

int main()
{
  string S;
  int j1, j2; // 0 = only year, 1 = both
  int tmp1, tmp2;

  cin >> S;

  tmp1 = (S[0]-'0')*10 + S[1]-'0';
  tmp2 = (S[2]-'0')*10 + S[3]-'0';

  if (tmp1==0 || tmp1>12){
    j1 = 0;
  }else {
    j1 = 1;
  }
  if (tmp2==0 || tmp2>12){
    j2 = 0;
  }else {
    j2 = 1;
  }

  if (j1==0 && j2==1){
    cout << "YYMM" << endl;
  }else if (j1==1 && j2==0){
    cout << "MMYY" << endl;
  }else if (j1==1 && j2==1){
    cout << "AMBIGUOUS" << endl;
  }else {
    cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAX_M = 200010;
// code
//#define int long long
ll S, ans = 0  ; 
 
ll cnt(ll x) {
	if(x == 0) return 0;
	return cnt(x / 10) + 1;
}
 
ll pow_mod(ll x, ll y)
{
    if (!y) return 1;
    ll t = pow_mod(x, y / 2);
    if (y % 2) return t * t % mod * x % mod;
    return t * t % mod;
}
 
void Solve(){
    cin >> S;
    ll r = 1, sub = 0 ; 
    for (ll l = 1; l < 1e7; l++)
    {
        while (sub + cnt(r) <= S) sub += cnt(r), r++;
        if (sub == S) ans++;
        sub -= cnt(l);
    }  
    for (ll dig = 8; dig <= S; dig++){
        ll r = S % dig;
        if (r == 0){
            ans = (ans  + pow_mod(10, dig) - pow_mod(10, dig - 1) - S / dig + 1 + mod) % mod;   
            r = dig;
        }
        ll val = r * (dig + 1);
        ll c = 1ll * dig * (dig + 1);
        if (val < S) ans = (ans + (S - val) / c + ((S - val) % c > 0)) % mod;  
    }
    cout << ans % mod;
}
 
signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


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

#define all(v) begin(v), end(v)
#define endl '\n';
#define int long long
#define pii pair<int, int>

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

    int x, y;
    cin >> x >> y;
    int a = 4*x - y;
    if (a & 1 || a < 0) {
        cout << "No" << endl;
    }
    else {
        a /= 2;
        if (a > x) {
            cout << "No" << endl;
        }
        else { 
            if (2*a + 4*(x-a) == y) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
    }


}

Measured memory_bytes: 3644
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, k] <- getIntList
  as <- getIntVec n

  let calcNCut i x res
        | i == n = res
        | otherwise = let a = as V.! i
                          m = (a+x-1) `div` x - 1
                      in calcNCut (i+1) x (res+m)

      isOk x = calcNCut 0 x 0 <= k

      solve ng ok | ok - ng <= 1  = ok
                  | otherwise = let m = (ok + ng) `div` 2
                                    (ok', ng') = if isOk m then (m, ng) else (ok, m)
                              in solve ng' ok'

  print $ solve 0 inf

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

int main(){
    int a,b;cin>>a>>b;
    
    if(min(100.0/8.0*(a+1),10.0*(b+1))>max(100.0/8.0*a,10.0*b)){
        for(int i=0;;i++)if(i>=max(100.0/8.0*a,10.0*b)){
          cout<<i<<endl;return 0;
        }  
    }
    else cout<<-1<<endl;return 0;
}

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

#define int long long

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

#define INF (3e9)

using namespace std;

int N, K;
int x[51];
int y[51];
bool used[51];

signed main()
{
    cin >> N >> K;
    REP(i, N) cin >> x[i] >> y[i];

    int ans = -1;
    REP (i, N)
    for (int j = i+1; j < N; ++j)
    REP (m, N)
    for (int n = m+1; n < N; ++n)
    {
        int x1 = min(x[i], x[j]);
        int x2 = max(x[i], x[j]);
        int y1 = min(y[m], y[n]);
        int y2 = max(y[m], y[n]);

        int num = 0;
        REP(k, N)
        {
            if (x1 <= x[k] && x[k] <= x2 && y1 <= y[k] && y[k] <= y2) ++num;
        }

        int s = abs(x2 - x1) * abs(y2 - y1);
        if (num >= K)
        {
            ans = ans == -1 ? s : min(ans, s);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> V(M);
    int B=0;
    for(int i = 0; i < M; i++){
        cin >> V.at(i);
        B = B + V.at(i);
    }
    if(B > N){
        cout << -1 << endl;
    }
    else{
        cout << (N - B) << endl; 
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int a[105],b[105];
int N;
int main()
{
	scanf("%d",&N);
	int cnt=N;
	for (int i=1;i<=N;i++)
	  scanf("%d",&a[i]);
	for (int i=cnt;i>=1;i--)
	  {
	  	for (int j=N;j>=1;j--)
	  		//cout<<j<<endl;
	  	    if (a[j]==j)
	  	     {
			  	for (int k=j;k<=N-1;k++)
			  	  a[k]=a[k+1];
			  	a[N]=0;
			  	b[i]=j;
			  	N--;
			  	break;
		    }
        }
 	if (N!=0) printf("-1");
 	else 
	 for (int i=1;i<=cnt;i++)
 	   printf("%d\n",b[i]);    
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N+1];
        int count = 1;
        
        
        for(int i = 1; i <= N; i++) {
           H[i] = sc.nextInt();
        }

        int max = H[1];
        for(int i = 2; i <= N; i++) {
            if (H[i] >= max){
                max = H[i];
                if(  H[i-1] <= H[i]) {
                    count++;
              }
            }
        }
        System.out.println(count);
    }
} 

Measured memory_bytes: 22868
function Main(input) {
  input = input.split("\n");
  var A = parseInt(input[0].split(" ")[0]);
  var B = parseInt(input[0].split(" ")[1]);
  var C = parseInt(input[0].split(" ")[2]);
  var ans = "No";
  if(C>B&&C<A){
    ans="Yes";
  }else if(C>A&&C<B){
    ans="Yes";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static bool[] check = new bool[105000];
        static int[] s = new int[10001];
        static void Main(string[] args)
        {
            int end = (int)Math.Sqrt(105000) + 1;
            for (int i = 2; i < end; i++)
            {
                if (check[i]) continue;
                for (int j = 2; i * j < 105000; j++)
                {
                    check[i * j] = true;
                }
            }
            for (int i = 2, index = 1; index < 10001 && i < 105000; i++)
            {
                if (check[i]) continue;
                s[index] = i + s[index - 1];
                index++;
            }
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                if (line == "0") break;
                var n = int.Parse(line);
                Console.WriteLine(s[n]);
            }
        }
    }
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    int x;
    cin >> x;
    int ukup=0;
    bool ch=false;
    for(int i=2; i<=n; i++){
        int a;
        cin >> a;
        if(a == x && !ch){
            ch = true;
            ukup++;
        }
        else{
            ch = false;
        }
        x = a;
    }
    cout << ukup;
    return 0;
}


Measured memory_bytes: 256
let q, h, s, d = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d
let n = Scanf.scanf " %d" @@ (+) 0
let m0_5 = min h @@ q * 2
let m1 = min s @@ m0_5 * 2
let m2 = min d @@ m1 * 2
let c2 = n / 2
let c1 = n - c2 * 2
let _ = c2 * m2 + c1 * m1 |> Printf.printf "%d\n"

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

int mat[100003];

int solve(int arr[] , int pos){
	
	if(pos==0){
		return 0;
	}
	else{
//		  p1 = 
//		  cout<<p1<<"\n";
	if(mat[pos]!=-1){
		return mat[pos];
	}

		if(pos>1){
		  return   mat[pos] =  min( solve(arr , pos-1) + abs(arr[pos] - arr[pos-1] ) ,  solve(arr , pos-2) + abs(arr[pos] - arr[pos-2] ) );	
//		  cout<<p2<<"\n";
		}
		else{
			return mat[pos] = solve(arr , pos-1) + abs(arr[pos] - arr[pos-1] ); 
		}
//		return min(p1,p2);
	}
}

int main()
{


memset( mat , -1 ,  sizeof(mat) );
int n;
cin>>n;

int arr[n] , i;

for(i=0;i<n;i++){
	cin>>arr[i];
}
int size = sizeof(arr)/sizeof(int); 

cout<<solve(arr , size-1 );

   return 0;
}


Measured memory_bytes: 8276
//#include <bits / stdc++.h>
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>

using namespace std;

int main() {
    int n;
    cin >> n ;
    vector<int> a(n), b(n), c(n - 1);
    
    for (int& x : a)
        cin >> x;
    for (int& x : b)
        cin >> x;
    for (int& x : c)
        cin >> x;
    /*
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n - 1; i++)
        cin >> c[i];
     */   
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += b[i];
        if (a[i] + 1 == a[i + 1])
            ans += c[a[i]-1];
    }
    cout << ans+b[n-1] << endl;
    
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
//mleしなければぜんぶllでかく。

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int n;
      cin>>n;
      int l[n];
      rep0(i,n) cin>>l[i];
      sort(l,l+n);
      int s=0;
      rep0(i,n-1) s+=l[i];
      if(s<=l[n-1]) cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
      return 0;
}

Measured memory_bytes: 384
using System;

class Range{
    static void Main(){
        
        string str = Console.ReadLine();
        string[] s = str.Split(' ');
        var a = int.Parse(s[0]);
        var b = int.Parse(s[1]);
        var c = int.Parse(s[2]);
        
        if (a < b && b < c){
            Console.WriteLine("Yes");
        }
        else {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8956
n, m = map(int, input().split())

fact = []
for i in range(1, int(m**0.5)):
    if m%i==0:
        fact.append(i)
        fact.append(m//i)
fact.sort()

ans = 1
for i in fact:
    if n*i<=m: ans = i
print(ans)

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

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int main() {
    int n = iin();
    char s[n];
    stin(s);
    int min = n, p = 0, lb = 0, rw = 0, i;
    REP(i,n) if (s[i] == '.') rw++;
    if (min > lb + rw) min = lb + rw;
    REP(i,n) {
        if (s[i] == '#') lb++;
        else rw--;
        if (min > lb + rw) min = lb + rw;
    }
    iout(min);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int k, t, a[100], y=0;
	cin >> k >> t;
	for(int i=0; i<t; i++){
		cin >> a[i];
	}
	sort(a, a+t);
	int x=1<<30;
	for(int i=0; i<t; i++){
		y+=a[i];
		k-=a[i];
		x=min(x, abs(y-k));
	}
	if(x==0){
		cout << 0 << endl;
	} else {
		cout << x-1 << endl;
	}

	return 0;
}


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

const int mxN = 2e5 + 10;
ll  n, k;
ll arr[mxN];

bool check(ll mid){
	int m = 0;
	for(int i = 0; i < n; i++){
		int c = arr[i] / mid;
		if(c == 0) continue;
		long double val = (arr[i] * 1.0) / (c * 1.0 );
		if(val > mid) c++;
		c--;
		m += c;
		if(m > k) return false;
	}
	return true;
}

void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}

	ll low = 1;
	ll  high = 1e12;
	while(low <= high){
		ll mid = ( low+ high ) / 2;
		if(check(mid)) high = mid - 1;
		else low = mid + 1;
	}
	cout << low  << "\n";
}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t = 1;

	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 5156
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[3];
		for(int i=0;i<n;i++) {
			a[sc.nextInt() % 3]++;
		}
		int max = 1;
		if (a[1] > 0) {
			int score = 0;
			int[] b = Arrays.copyOf(a, 3);
			b[1]--; score++;
			while(true) {
				if (b[1] <= 0) break;
				b[1]--; score++;
				if (b[2] <= 0) break;
				b[2]--; score++;
			}
			score += b[0];
			if (b[1] > 0 || b[2] > 0) score++;
			max = Math.max(max, score);
		}
		if (a[2] > 0) {
			int score = 0;
			int[] b = Arrays.copyOf(a, 3);
			b[2]--; score++;
			while(true) {
				if (b[2] <= 0) break;
				b[2]--; score++;
				if (b[1] <= 0) break;
				b[1]--; score++;
			}
			score += b[0];
			if (b[1] > 0 || b[2] > 0) score++;
			max = Math.max(max, score);
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 166840
n = int(input())
ans = [0] * 10010

def get_ans(n):
  cnt = 0
  for x in range(1, 101):
    for y in range(1, 101):
      for z in range(1, 101):
        k = x**2 + y**2 + z**2 + x*y + y*z + z*x
        if(k <= 10000):
          ans[k] += 1        
  return ans

ans = get_ans(n)
for i in range(1, n+1):
  print(ans[i])

Measured memory_bytes: 74060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    string v[] = {"AC", "WA", "TLE", "RE"};
    int N; cin>>N;
    int cnt[4]={0};
    for (int i = 0; i < N; ++i) {
        string a; cin>>a;
        for(int j=0;j<4;++j){
            if(a==v[j]) cnt[j]++;
        }
    }
    for (int i = 0; i < 4; ++i) {
        cout<<v[i]<<" x "<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] f = new int[100][100];
        int[][] p = new int[100][100];
        for(int i = 0;i < n;i++){
            for(int j = 0;j < 10;j++){
                f[i][j] = sc.nextInt();
            }
        }
        for(int i = 0;i < n;i++){
            for(int j = 0;j <= 10;j++){
                p[i][j] = sc.nextInt();
            }
        }

        int res = Integer.MIN_VALUE;
        for(int bit = 1; bit < (1<<10);bit++){
            int cc = 0;
            for(int i = 0;i < n;i++){
                int c = 0;
                for(int j = 0;j < 10;j++){
                    if((bit >> j&1) == 1&& f[i][j] == 1){
                        c++;
                    }
                }
                cc += p[i][c];
                //System.out.println("cc = " + cc);
            }
            res = Math.max(res,cc);
            //System.out.printf("b = %d ,res = %d\n",bit,res);
        }
        System.out.println(res);
    }
}


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

using namespace std;

const int N =1e5 + 5;

int cnt(int x)
{
    int sum = 0;
    while(x)
    {
        sum += x%10;
        x/=10;
    }
    return sum;
}
int main() {

    int n;
    cin>>n;
    int ans = 1e9;
    for(int i = 1 ; i< n ; ++i)
    {
        ans = min(ans , cnt(i) + cnt(n-i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int,input().split()))
dp=[0]*(K+1)
for i in range(K+1):
  for j in A:
    if (i>=j) and (dp[i-j]==0):
      dp[i]=1
if dp[K]:
  print('First')
else:
  print('Second')

Measured memory_bytes: 41580
#include <iostream>

using namespace std;

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

	cin >> a >> b >> c;
    
    int x = c % a;
	int y = 1;

	while (true) {
		if (((b * y) % a + x) % a == 0) {
			cout << "YES" << endl;
			break;
		}
		else if (((b * y) % a + x) % a == x) {
			cout << "NO" << endl;
			break;
		}

		y++;
	}
}

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

using namespace std;

#define pii pair<int, int>

struct UF {
    vector<int> a;
    UF(int n) {
        a.resize(n, -1);
    }
    int root(int i) {
        return a[i] < 0 ? i : a[i] = root(a[i]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    void unite(int x, int y) {
        x=root(x), y=root(y);
        if (x==y) return;
        if (-a[x] < -a[y]) swap(x, y);
        a[x] += a[y];
        a[y] = x;
    }
};

struct edge {
    int c, u, v;
    edge(int c, int u, int v) : c(c), u(u), v(v) {};
};

bool operator<(const edge& a, const edge& b) {
    return a.c < b.c;
}

int main()
{
    int n; cin >> n;
    vector<pii> A, B;
    for (int i = 0; i < n; ++i) {
        int a, b; cin >> a >> b;
        A.push_back(pii(a, i));
        B.push_back(pii(b, i));
    }
    
    sort(begin(A), end(A));
    sort(begin(B), end(B));
    
    vector<edge> edges;

    for (int i = 0; i < n - 1; ++i) {
        edge e1 = edge(abs(A[i].first - A[i + 1].first), A[i].second, A[i+1].second);
        edge e2 = edge(abs(B[i].first - B[i + 1].first), B[i].second, B[i+1].second);

        edges.push_back(e1);
        edges.push_back(e2);
    }

    sort(begin(edges), end(edges));
    
    UF uf(n);

    long long ans = 0;
    
    for (int i = 0; i < (int)edges.size(); ++i) {
        if (uf.same(edges[i].u, edges[i].v)) continue;
        
        ans += edges[i].c;
        
        uf.unite(edges[i].u, edges[i].v);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 7144
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y;
}a[500010];
int n,v[5000010];
bool cmp(aaa a,aaa b){
	return a.x<b.x;
}
bool cmp1(aaa a,aaa b){
	return a.x>b.x;
}
int main(){
	int i,now,la;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i].x);
		a[i].y=i;v[a[i].x]=i;
	}
	sort(a+1,a+n+1,cmp);
	la=1;
	for(i=1;i<=n;i++){
		now=a[i].y-1;
		while(now){
			while(v[la])la++;
			if(la>a[i].x)return puts("No"),0;
			v[la]=a[i].y;now--;
		}
	}
	la=n*n;
	sort(a+1,a+n+1,cmp1);
	for(i=1;i<=n;i++){
		now=n-a[i].y;
		while(now){
			while(v[la])la--;
			if(la<a[i].x)return puts("No"),0;
			v[la]=a[i].y;now--;
		}
	}
	puts("Yes");
	for(i=1;i<=n*n;i++)printf("%d ",v[i]);
}

Measured memory_bytes: 4224
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
	while(1){
		long n;
		scanf(" %ld", &n);
		if(n==0) break;
		
		long s=1;
		for(long i=2; i<=sqrt(n); ++i){
			if(n%i==0){
				if(i==n/i) s+=i;
				else s+=i+n/i;
			}
		}
		
		string ans;
		if(n==1 || s<n) ans="deficient number";
		else if(s==n) ans="perfect number";
		else ans="abundant number";
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1208