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

int main(){
   int N;
   std::cin >> N;
   std::vector<int> a(N);
   std::map<int,int> b;
   for(int i=0; i<N; ++i){
      std::cin >> a[i];
      if(b.find(a[i])==b.end()) b[a[i]] = 1;
      else b[a[i]] += 1;
   }

   int ans = 0;
   for(auto itr=b.begin(); itr!=b.end(); ++itr){
      int n = itr->second;
      if(n<itr->first){
	 ans += n;
      }else if(n>itr->first){
	 ans += n - itr->first;
      }
   }
   std::cout << ans << std::endl;
   return 0;

}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;
 
int main(){
    ll N, M; cin >> N >> M;
    vector<int> vec(N);
    ll sum = 0;
    for(int i=0; i<N; i++){
      ll p; cin >> p;
      sum += p; vec[i] = p;
    }
    sort(vec.begin(), vec.end());
    bool ans = true;
    long double m = M;
    for(int i=0; i<M; i++){
        if(vec[N-i-1] < sum/(4*m)){
            ans = false;
        }
    }
    if(ans == true){cout << "Yes";}
    else{cout << "No";}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = {61,230,865,3247,12185,45719,171531,643550,2414454,9058467,33985227,127504505,478366600,794717734,733354121,261943303,776803305,580025381,51688048,44657419,737209731,604119499,159693437,858533109,639056669,549054109,996291083,531294469,23314687,783022045,855462856,649970414,68697295,409213624,604356692,88638656,978442997,534833116,763737161,785892908,123883652,639213333,181836645,998121103,124885216,501575626,39816123,113468411,799008836,775465589,256852905,664630886,971550783,751629411,51018086,702530485,725438992,696683714,792638194,221791721,149602322,414054379,986519078,981760191,305799096,515140586,406959393,975058685,245601370,324759692,673385295,191483611,570246669,427196161,781042769,569725155,842176273,25328739,847501730,206282374,353770801,323137024,371653459,940737264,123820509,915711339,847205021,252858375,718889563,866398347,738390145,133009077,333099663,170591295,329869205,616680192,597534442,388130742};
        int N = sc.nextInt()-3;
        System.out.println(arr[N]);
    }
}


Measured memory_bytes: 23124
#define DEBUG
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
#define all(x) begin(x), end(x)
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
#define TCC template<class C
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
#define ENI typename enable_if<
#define DTOR , Dbg&>::type operator<<
#define RIS return *this
TCC> static auto o(C *x)->decltype(os << *x, 0);
TCC> static char o(...);
TCC> ENI sizeof o<C>(0)!=1 DTOR(const C &x) {os<<x; RIS;}
TCC> Dbg &dump(C b, C e) {
    int ii = 0;
    for(C i = (os << "\n[", b); i!=e and ii<26; i++, ii++) *this << ", "+2*(i==b) << *i;
    RIS << ']';
}
TCC> ENI sizeof o<C>(0)==1 DTOR(const C &x) {
    return dump(all(x));
}
TCC, size_t X> ENI !is_same<C, const char>::value DTOR(C (&x)[X]) {
    return dump(all(x));
}
TCC, class D> Dbg &operator<<(const pair<C, D> &x) {RIS<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(ostream&)) { os << x; RIS; }
} dbg;
void err(istringstream *iss) { delete iss; }
TCC, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#ifdef DEBUG
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#else
#define bug(args...) 0
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
int T = 1, Q, cn;
const int inf = 1000000007, mxn = 85;
#define int ll
int n,a[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    // cin >> T;
    auto inputAll = [&]()->void {
        
    };
    auto kase = [&]()->void {
        // cout << "Case " << cn << ": ";
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i];
        int money=1000,share=0;
        for(int i=1;i<n;i++){
            if(a[i]<a[i+1]){
                int o=money/a[i];
                share+=o,money-=o*a[i];
            } else if(a[i]>a[i+1]){
                money+=a[i]*share,share=0;
            }
        }
        money+=a[n]*share,share=0;
        cout<<money<<'\n';
    };
    auto resetAll = [&]()->void {
        
    };
    while (cn++!=T) inputAll(), kase(), resetAll();
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    int a[3] = {};
    for(int i=0; i<s.length(); i++) a[s[i]-'a']++;
    sort(a, a+3);
    if(a[2] - a[0] <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
n, c, k = map(int, input().split())
T = sorted([ int(input()) for _ in range(n) ])
ans = 0
count = 0
bus = T[0] + k
for i in range(n):
  if not (T[i] <= bus <= T[i]+k) or count >= c:
    ans += 1
    bus = T[i]+k
    count = 0
  count += 1
if count > 0:
  ans += 1
print(ans)

Measured memory_bytes: 8280
import java.util.Arrays;

import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		
		String[] S = new String[N];
		
		for(int i=0 ; i<N ;i++){
			S[i]=sc.next();
		}
		
		Arrays.sort(S);
		
		


        for (int i = 0; i < S.length; i++) {

               System.out.print(S[i]);

        }

		

	}

}

Measured memory_bytes: 9812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    string s;
    cin>>s;
    if(s[sz(s)-1]=='s'){
        s+='e';
        s+='s';
    }else{
        s+='s';
    }
    cout<<s<<endl;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int A;
    static int B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();
        System.out.println( solve() );
    }

    private static String solve() {
        String yay = "Yay!";
        String boo = ":(";

        if( A <= 8 && B <= 8 ) {
            return yay;
        } else {
            return boo;
        }
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

template<class Compare>
VI slide_minmax(const VI &v, const int k) {
  deque<int> qq;
  VI ret;
  Compare cmp = Compare();
  rep(i, v.size()) {
    while(!qq.empty() && cmp(v[qq.back()], v[i])) {
      qq.pop_back();
    }
    qq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[qq.front()]);
      if(qq.front() == i - k + 1) qq.pop_front();
    }
  }
  return ret;

}

struct UnionFind {
  std::vector<int> parents;
  std::vector<int> sz;
  std::vector<int> drank;

  UnionFind(int n) {
    parents = std::vector<int>(n);
    std::iota(parents.begin(), parents.end(), 0);
    drank.assign(n, 0);
    sz.assign(n, 1);
  }

  int root(int x) {
    if(parents[x] == x) {
      return x;
    }
    else {
      return parents[x] = root(parents[x]);
    }
  }

  void unite(int x, int y) {
    int parx = root(x);
    int pary = root(y);
    if(parx == pary) return;
    else if(drank[parx] < drank[pary]) {
      int tmp = sz[parx] + sz[pary];
      sz[parx] = sz[pary] = tmp;
      parents[parx] = pary;
    }
    else {
      int tmp = sz[parx] + sz[pary];
      sz[parx] = sz[pary] = tmp;
      parents[pary] = parx;
      if(drank[parx] == drank[pary]) drank[parx]++;
    }
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return sz[x];
  }
};



signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VI p(n);
  rep(i, n) cin >> p[i];
  VI a = slide_minmax<less<int>>(p, k+1);
  VI b = slide_minmax<greater<int>>(p, k+1);
  UnionFind un = UnionFind(n + 1);
  for(int i = 0; i + k < n; ++i) {
    if(b[i] == p[i] && a[i] == p[i + k]) {
      un.unite(i, i+1);
    }
  }
  VI sorted(n, 0);
  rep(i, n-1) sorted[i+1] = p[i] > p[i+1];
  rep(i, n-1) sorted[i+1] += sorted[i];
  rep(i, n - k + 1) if(sorted[i] == sorted[i + k - 1]) un.unite(i, n);
  int ans = 0;
  rep(i,n-k+1)if(un.root(i) == i) ans++;
  out(ans);
  return 0;
}


Measured memory_bytes: 5880
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		ll r,d,x;
		cin>>r>>d>>x;
		// n=s.length();
		// ll a[n];
		rep(i,10)
		{
			x=r*x-d;
			cout<<x<<"\n";
		}
		// cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

# 現在末尾に追加される山より若い山で，最も個数の大きいものが次の山になる
# 他の山を次の山の個数以下まで減らす

ans = [0] * N

numList = [(a, i) for i, a in enumerate(A)]
numList.sort(reverse=True)
numList.append((0, 0))

y = float('inf')
for c, (a, i) in enumerate(numList[: N], start=1):
    y = min(y, i)
    ans[y] += c * (a - numList[c][0])

print(*ans, sep='\n')

Measured memory_bytes: 23820
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;


int main(){
    int n, m , number, wa, ac, wa2;
    wa = 0; ac = 0; wa2 = 0;
    string data;
    cin >> n >> m;
    
    vector< vector<string> >  result(n + 1);
    result.at(0) = {"default"};
    rep( i , m){
        cin >> number >> data;
        result.at(number).push_back(data);
    }
    rep(i , n){
        bool ok = true;
        for ( string j : result.at(i)){
            if ( (j == "WA") & ok)
                wa2++;
            if ( (j == "AC") & ok){
                ac++;
                ok = false;
            }
                
        }
        if ( not( ok))
            wa += wa2;
        wa2 = 0;
    }
    cout << ac  << ' ' << wa << endl;
    
    
}


Measured memory_bytes: 10320
#include <stdio.h>
#include <math.h>

struct Point { double x, y; };

void koch(int n, Point a, Point b){
  if(n == 0)return;
  Point s, t, u;
  double th = M_PI * 60.0/ 180.0;
  s.x = (2.0 * a.x +1.0*b.x) / 3.0;
  s.y = (2.0 * a.y +1.0 *b.y) / 3.0;
  t.x = (1.0 * a.x +2.0*b.x) / 3.0;
t.y = (1.0 * a.y +2.0 *b.y) / 3.0;
 u.x = (t.x - s.x)*cos(th) - (t.y - s.y)* sin(th) + s.x;
 u.y= (t.x - s.x)*sin(th) + (t.y - s.y)* cos(th) + s.y;

 koch(n-1, a, s);
 printf("%.8f %.8f\n", s.x, s.y);
 koch(n-1, s, u);
 printf("%.8f %.8f\n", u.x, u.y);
 koch(n-1, u, t);
 printf("%.8f %.8f\n", t.x, t.y);
 koch(n-1, t, b);

}

int main(){
  Point a, b;
  int n;
  scanf("%d", &n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}






Measured memory_bytes: 2740
#include<stdio.h>

int main(){
  long long int n,m,n1=1,m1=1,ans,i;
  scanf("%lld%lld",&n,&m);
  if(abs(n-m)<2){
    for(i=1;i<=n;i++){
      n1*=i;
      n1%=1000000007;
    }
    for(i=1;i<=m;i++){
      m1*=i;
      m1%=1000000007;
    }
    ans=(n1*m1);
    ans%=1000000007;
    if(n==m)ans*=2;
    ans%=1000000007;
    printf("%lld\n",ans);
  }
  else puts("0");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a, b, x;
    cin >> x >> a >> b;
    if(abs(x - a) > abs (x - b))
    {
        cout << "B" <<endl;
    }
    else
    {
        cout << "A" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] ary = new int[n];
        
        for(int i=0; i<n; i++){
            ary[i] = int.Parse(input[i]);
        }
        
        Array.Sort(ary);
        
        int ans = ary[n/2] - ary[n/2-1];
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 18912
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner s= new Scanner(System.in);
        String w=s.nextLine();
        if(w.equals("Sunny"))
            System.out.print("Cloudy");
        else if(w.equals("Cloudy"))
            System.out.print("Rainy");
        else
            System.out.print("Sunny");}
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d=0;
	while(c>0){
		d++;
		c-=a;
		if(d%7==0)c-=b;
	}
	cout<<d<<endl;
	return 0;
}


Measured memory_bytes: 3100
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
	
		// 出力
		System.out.println((a+b)*h/2);
	}
}

Measured memory_bytes: 20948
def count_diff(q,a):
    lst_q = list(q)
    lst_a = list(a)
    len_q = len(lst_q)
    ng = 0
    for i in range(len_q):
        if lst_q[i] != lst_a[i]:
            ng += 1
    print(ng)

q =input()
a =input()

count_diff(q,a)
                                                    
                                                    
                                                    
      

Measured memory_bytes: 12332
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
using namespace std;


int s[3] = { -1, -1, -1 };

void solve()
{
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		int ind, x;
		cin >> ind >> x;
		ind--;

		if (s[ind] != -1 && s[ind] != x)
		{
			cout << -1;
			return;
		}

		s[ind] = x;
	}

	if (n == 1 && s[0] == -1)
	{
		cout << 0;
		return;
	}

	if (n > 1 && s[0] == 0)
	{
		cout << -1;
		return;
	}

	for (int i = 0; i < n; i++)
	{
		int t = 0 + (i == 0);
		if (s[i] == -1)
		{
			s[i] = t;
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << s[i];
	}
}

int main()
{
	solve();
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

        int i, j ;

	for (i = 0 ; i < 9 ; i++)
		for (j = 0 ; j < 9 ; j++)
			printf("%dx%d=%d\n", i+1, j+1, (i+1)*(j+1)) ;
	
	return 0 ;

}

Measured memory_bytes: 924
pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);
 
impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn solve(s: String) -> &'static str {
    if s == "ABC" {
        "ARC"
    } else {
        "ABC"
    }
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let ans = solve(sc.read());
    println!("{}", ans);
}
 


Measured memory_bytes: 2160
#include<stdio.h>

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
    int H, i, A[1000];

    scanf("%d", &H);
    for(i=1; i<=H; i++){
        scanf("%d", &A[i]);
    }

    for(i=1; i<=H; i++){
        printf("node %d: key = %d, ", i, A[i]);
        if(parent(i)>=1) printf("parent key = %d, ", A[parent(i)]);
        if(left(i)<=H) printf("left key = %d, ", A[left(i)]);
        if(right(i)<=H) printf("right key = %d, ", A[right(i)]);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int n, m, q;
vi a, b, c, d;
vi A;
int ans = 0;

void dfs(int x, int depth) {
    if(depth == n) {
        int tmp = 0;
        rep(i, q) if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
        chmax(ans, tmp);
        return;
    }
    A[depth] = x;
    for(int i = x; i <= m; i++) dfs(i, depth + 1);
}

int main() {
//	cout << fixed << setprecision(15);
    cin >> n >> m >> q;
    a = vi(q);
    b = vi(q);
    c = vi(q);
    d = vi(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    A = vi(n);
    for(int i = 1; i <= m; i++) dfs(i, 0);
    cout << ans << endl;
}


Measured memory_bytes: 3644
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll one=(s[0]-'0')*10+(s[1]-'0');
    ll sec=(s[2]-'0')*10+(s[3]-'0');
    if(one<=12 && one>=1 && sec>=1 && sec<=12)
    {
    	cout<<"AMBIGUOUS"<<'\n';
    	return 0;
    }
    if(one<=12 && one>=1)
    {
    	cout<<"MMYY"<<'\n';
    	return 0;
    }
    if(sec>=1 && sec<=12)
    {
    	cout<<"YYMM"<<'\n';
    	return 0;
    }
    cout<<"NA"<<'\n';
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	if (a > b) swap(a, b);
	set<ll> div;
	for (ll i = 2; i * i <= a; i++) {
		while (a % i == 0) {
			div.insert(i);
			a /= i;
		}
	}
	if (a != 1) div.insert(a);
	int ans = 0;
	for (ll i : div) {
		if (b % i == 0) ans++;
	}
	cout << ans + 1 << endl;
	return 0;
}

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

int main()
{
    bool dp[3][3]={false};
    int v[3][3];
    int i,j,k;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>v[i][j];
        }
    }
    int n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        int ai;cin>>ai;
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
                if(v[j][k]==ai) dp[j][k]=true;
        }}
    }
    bool flag=false;
    for(i=0;i<3;i++)
    {
        if(dp[i][0]==true && dp[i][1]==true && dp[i][2]==true) flag=true;
        if(dp[0][i]==true && dp[1][i]==true && dp[2][i]==true) flag=true;
    }
    if(dp[0][0]==true && dp[1][1]==true && dp[2][2]==true ) flag=true;
    if(dp[2][0]==true && dp[1][1]==true && dp[0][2]==true ) flag=true;

    if(flag) cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

public class Main{
	public static void main(String[] args) {
		int a,b;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if(a <= 5){
			System.out.println(0);
		}
		else if(a >= 13){
			System.out.println(b);
		}
		else{
			System.out.println(b / 2);
		}
	}
}


Measured memory_bytes: 23764
import java.util.*;

class Main{
    public static void main(final String[] args){
        Scanner scan = new Scanner(System.in);
        int s = scan.nextInt();
        int w = scan.nextInt();
        
        if(s <= w){
            System.out.println("unsafe");
        }else{
            System.out.print("safe");
        }
    }    
}

Measured memory_bytes: 35756
import sys
def d(v1,v2):
    r = 0
    for x,y in zip(v1,v2):
        r += (x-y)**2
    if r == int(r**0.5) * int(r**0.5):
        return True
    return False


N, D = map(int, input().split())
vs = []
for line in sys.stdin:
    vs.append(list(map(int, line.split())))

rr = 0
for i in range(N):
    for j in range(N-i-1):
        if d(vs[i], vs[i+j+1]):
            rr += 1
print(rr)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>

#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)

typedef long long LL;
const int N=200005;

LL s[N],a[N],r[N],p[N],n;
LL w[N],q[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void dbg(LL m) {
	rep(j,1,m+1) w[j]=w[j-1]+s[j];
	rep(j,1,m+1) w[j]=w[j-1]+w[j];
	rep(j,1,m+1) q[j]=q[j-1]+p[j];
	rep(j,1,m+1) w[j]+=q[j];
	LL tmp=0;
	rep(j,1,m) printf("%lld ", w[j]); puts("");
	// rep(j,1,m) {
		// printf("%lld ", r[j]);
	// } puts("");
}

void add(LL l,LL r) {
	if (l>r) return ;
	s[l]++,s[r+1]--;
	p[r+1]-=r-l+1;
}

int main(void) {
	n=read(); LL m=read(),ans=0,mx=0;
	rep(i,1,n) a[i]=read();
	rep(i,2,n) {
		if (a[i-1]+1<=a[i]) {
			ans+=a[i]-a[i-1];
			add(a[i-1]+2,a[i]);
		} else {
			ans+=a[i]+m-a[i-1];
			add(a[i-1]+2,m);
			add(1,a[i]);
			p[1]+=m-a[i-1]-1,p[a[i]+1]-=m-a[i-1]-1;
		}
//		dbg(m);
	//	int ggg=0;
	}
	rep(i,1,m) s[i]+=s[i-1];
	rep(i,1,m) s[i]+=s[i-1];
	rep(i,1,m) p[i]+=p[i-1],s[i]+=p[i];
	rep(i,1,m) if (s[i]>mx) mx=s[i];
	printf("%lld\n", ans-mx);
//	for (int i=1;i<=m;++i) printf("%lld ", s[i]); puts("");
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=105;
char out[maxn][maxn];
int main()
{
    IO;
    int a,b;
    cin >> a >> b;
    for(int i=0;i<maxn;++i)
        for(int j=0;j<maxn;++j)
            out[i][j]='#';
    int mafesh=a-1;
    int hna=((a+32)/33)*3;
    int hna2=((b+32)/33)*3;
    cout<<hna+hna2<<" 99\n";
    for(int i=0;i<hna;i+=3){
        for(int k=i;k<i+3;++k)
            for(int j=0;j<99;++j)
                out[k][j]='#';
        for(int j=0;j<99;j+=3){
            if(!mafesh)break;
            --mafesh;
            for(int k=i;k<i+3;++k)
                for(int t=j;t<j+3;++t)
                    out[k][t]='#';
            out[i+1][j+1]='.';
        }
        if(!mafesh)break;
    }
    mafesh=b-1;
    for(int i=hna;i<hna+hna2;i+=3){
        for(int k=i;k<i+3;++k)
            for(int j=0;j<99;++j)
                out[k][j]='.';
        for(int j=0;j<99;j+=3){
            if(!mafesh)break;
            --mafesh;
            for(int k=i;k<i+3;++k)
                for(int t=j;t<j+3;++t)
                    out[k][t]='.';
            out[i+1][j+1]='#';
        }
        if(!mafesh)break;
    }
    for(int i=0;i<hna+hna2;++i,cout<<endl)
        for(int j=0;j<99;++j)
            cout<<out[i][j];
    re 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		Scanner	sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (n*a > b) {
			System.out.println(b);
		} else {
			System.out.println(n*a);
		}
	}
		
}
	
	


Measured memory_bytes: 21716
# Author: cr4zjh0bp
# Created: Sat Mar 14 10:58:59 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

c = nsn(2)

flag = True
for i in range(3):
    if c[0][i] != c[1][3 - i - 1]:
        flag = False

print("YES" if flag else "NO")

Measured memory_bytes: 3064
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    string str;
    cin >> str;

    string year = str.substr(0, 4);
    string month = str.substr(5, 2);
    string day = str.substr(8, 2);

    if (year >= "2019" && month >= "05") cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}


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

int main(){
  ll n,i,j,k;
  cin >> n;
  vector<ll> l(n);
  for(i=0;i<n;i++){
    cin >> l.at(i);
  }
  
  ll a=0;
  for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
      for(k=j+1;k<n;k++){
        if(l.at(i)+l.at(j)>l.at(k)&&l.at(j)+l.at(k)>l.at(i)&&l.at(k)+l.at(i)>l.at(j)
          &&l.at(i)!=l.at(j)&&l.at(j)!=l.at(k)&&l.at(k)!=l.at(i)){
          a++;
        }
      }
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
  int n;
  int score[2]={0,0};
  int i,j,first=0;
  char taro[100],hanako[100];
 
  scanf("%d",&n);
  for(j=0;j<n;j++)
    {
      for(i=0;;i++)
    {
      scanf("%c",&taro[i]);
      if(first==0)
        {
          i--;
          first++;
        }
      if(taro[i]==' ') break;
    }
      for(i=0;;i++)
    {
      scanf("%c",&hanako[i]);
      if(hanako[i]=='\n') break;
    }
      for(i=0;;i++)
    {
      if((taro[i]==' ')&&(hanako[i]=='\n'))
        {
          score[0]+=1;
          score[1]+=1;
          break;
        }
      if((taro[i]==' ')&&(hanako[i]!='\n'))
        {
          score[1]+=3;
          break;
        }
      if((taro[i]!=' ')&&(hanako[i]=='\n'))
        {
          score[0]+=3;
          break;
        }
      if(taro[i]>hanako[i])
        {
          score[0]+=3;
          break;
        }
      if(taro[i]<hanako[i])
        {
          score[1]+=3;
          break;
        }
    }
    }
  printf("%d %d\n",score[0],score[1]);
  return 0;
}




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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;
    ll cn = n;

    ll t = 26;
    ll cnt = 0;
    while (cn > 0) {
        cn -= t;
        cnt++;
        t *= 26;
    }

    t /= 26; // 文字列の範囲 676とか
    cn += t; // その中で何番目か
    cn--;

    string ans = "";
    for (ll i = 0; i < cnt; ++i) {
        ans += 'a';
    }

    ll k = t / 26;
    for (ll i = 0; i < cnt; ++i) {
        ll jun = cn / k;
        ans[i] = 'a' + jun;

        cn -= k * jun;
        k /= 26;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;
 
class event implements Comparable<event>{
		public int a;
		public int b;
		public event(int a , int b){
			this.a = a;
			this.b = b;
		}
		
		public int compareTo(event other){
			// return b - other.b;
			return Integer.compare(b , other.b);
		}
		
}
 
public class Main{
 
 
	
	public static void main(String[] args) {
			
		       Scanner in = new Scanner(System.in);
                       int N = in.nextInt();
                       int[] size = new int[2];
                       event[] vs = new event[2*N];
                       for (int x=0; x<2; x++)
                            for (int i=0; i<N; i++)
                                         vs[i+x*N] = new event(x, in.nextInt());
 
                      Arrays.sort(vs);
 
                  long mod = 1_000_000_007;
                  long res = 1L;
                  for (event e : vs)
                  {
                     if (size[1 - e.a] > 0){
                       res *= size[1 - e.a];
                       res %= mod;
 
                       size[1 - e.a]--;
                  }
                   else
                   {
                        size[e.a]++;
                    }
               }
			
			System.out.println(res);
 
	}
 
}

Measured memory_bytes: 96468
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b;
string s;
signed main()
{
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b});
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define amod 998244353
#define mod 1e9 + 7
#define ll long long

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

  int a, b, x, y;
  cin >> x >> y;

  b = (y - 2 * x) / 2;
  a = x - b;

  if (a < 0 || b < 0 || 2 * a + 4 * b != y)
    cout << "No\n";
  else
    cout << "Yes\n";

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vi h(n); rep(i,n) cin >> h[i];
    int  max_h = 0;
    bool can = true;
    for(int i = n-1; i > 0; i--){
        if(h[i] > h[i-1]) continue;
        else if(h[i] == h[i-1]-1) h[i-1] -= 1;
        else if(h[i] < h[i-1]-1){
            can =false;
            break;
        }
    }
    cout << (can ? "Yes" : "No" ) << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n*n;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
  int n,m,c;
  int ans = 0;
  int a,b[25];
  
  scanf("%d %d %d", &n,&m,&c);
  for(int i=0;i<m;i++){
    scanf("%d", &b[i]);
  }
  for(int i=0;i<n;i++){
    int sum=0;
  	for(int j=0;j<m;j++){
    	scanf("%d", &a);
      sum += b[j]*a;
    }
    if(sum+c>0){
      ans++;
    }
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 1728
from collections import Counter

n=int(input())
l=[input() for i in range(n)]

if Counter(l).most_common()[0][1] != 1:
  ans="No"
else:
  l_head = [l[i+1][0] for i in range(n-1)]
  l_tail = [l[i][-1] for i in range(n-1)]
  if l_head == l_tail:
    ans="Yes"
  else:
    ans="No"
    
print(ans)
  

Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	rep(i,0,c-a) cout<<"R";
	rep(i,0,d-b) cout<<"U";
	rep(i,0,c-a) cout<<"L";
	rep(i,0,d-b) cout<<"D";
	cout<<"D";
	rep(i,0,c-a+1) cout<<"R";
	rep(i,0,d-b+1) cout<<"U";
	cout<<"L";
	cout<<"U";
	rep(i,0,c-a+1) cout<<"L";
	rep(i,0,d-b+1) cout<<"D";
	cout<<"R"<<endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var L=Arr.shift();
for(var i=0;i<L;i++){
   console.log("Case "+(i+1)+":");
   var v=Arr[i];
   for(var j=0;j<10;j++){
      v="000000"+(v*v);
      v=v.slice(-6);
      v=v.slice(0,4);
      v=parseInt(v,10);
      console.log(v);
   }
}

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

using namespace std;

#define N 100100
#define SIGMA 26

int ans[N];
int n, m, ok, i, x, y;
int main()
{
    cin >> n >> m;
    for (i = 0; i < n; ++i)
        ans[i] = -1;
    ok = 1;
    for (i = 0; i < m; ++i){
        cin >> x >> y;
        --x;
        if (ans[x] > -1 && ans[x] != y)
            ok = 0;
        else{
            ans[x] = y;
        }
    }
    if (!ok){
        cout << "-1";
        return 0;
    }
    if (ans[0] == 0 && n > 1){
        cout << "-1";
        return 0;
    }
    if (ans[0] == -1){
        if (n > 1)
            ans[0] = 1;
        else
            ans[0] = 0;
    }
    for (i = 0; i < n; ++i)
        if (ans[i] == -1)
        cout << '0';
    else
        cout << ans[i];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//#define MD 1
#define MD 1000000007
 
int main(){
    long long int n;
    cin>>n;
    vector<long long int> v(10002);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    long long int ans=0,cnt=0,flag=0;
    for(int i=0;i<n;i++){
        while(v[i]%2==0){
            ans++;
            v[i]/=2;
        }
    }
    cout<<ans<<endl;
    /*while(1){
        for(int i=0;i<n;i++){
            if(v[i]%2==0 && flag==0 && v[i]>1){
                v[i]/=2;
                flag=1;
            }else{
                v[i]*=3;
                cnt++;
            }
        }
        if(cnt!=n){
                ans++;
                flag=0;
                cnt=0;
        }else{
            cout<<ans<<endl;
            break;
       }
    }*/
     return 0;
}

Measured memory_bytes: 896
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
uvw = [LIST() for _ in range(N-1)]

graph = defaultdict(list)

for u, v, w in uvw:
	graph[u-1].append((v-1, w))
	graph[v-1].append((u-1, w))

#print(graph)

colors=[0]*N
colors[0]=1

def DFS(node):
	for x, w in graph[node]:
		if not colors[x]:
			if w%2:
				colors[x] = colors[node]*(-1)
			else:
				colors[x] = colors[node]
			DFS(x)

DFS(0)

#print(colors)

for x in colors:
	if x == 1:
		print(0)
	else:
		print(1)





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

ll N, A[100005][3], dp[100005][3];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N;
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}

	ll ans = 0;
	for (ll i = 0; i < 3; i++) {
		dp[0][i] = A[0][i];
		ans = max(ans, dp[0][i]);
	}

	for (ll i = 1; i < N; i++) {
		for (ll j = 0; j < 3; j++) {
			for (ll k = 0; k < 3; k++) {
				if (k != j) {
					dp[i][j] = max(dp[i][j], dp[i-1][k] + A[i][j]);
				}
			}
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};
using Graph = vector<vector<int> >;

int main() {
    int a,b,c,k; cin >> a >> b >> c >> k;
    int ans = 0;
    if(a>=k){
	ans = k;
    }else{
	ans += a;
	k = k-a;
	if(k>b) ans -= (k-b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#define ll long long
#define out(a) printf("%d ",a)
#define ln printf("\n")
const int N=1e5+50;
const int MOD=1e9+7;
const int inf=0x7f7f7f7f;
using namespace std;
int a,b;
int ans=0;
int main()
{
	scanf("%d%d",&a,&b);
	for (int i=max(-1000000,b-a+1);i<=min(1000000,b+a-1);i++)
	  out(i);
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, T, ans=0;
	int A[100005], mn=INF;
	map<int,int> cnt;

	cin >> N >> T;
	rep(i,N){
		cin >> A[i];
		int profit = A[i] - mn;
		cnt[profit]++;
		chmin(mn, A[i]);
	}

	ans = cnt.rbegin()->second;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll sum = accumulate(A.begin(), A.end(), 0LL);
    ll ans = INF;
    ll s = 0;
    rep(i, N - 1) {
        s += A[i];
        ans = min(ans, abs(sum - s - s));
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1792
#include <math.h>

#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << endl;
    } else if (a + b >= k) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 5e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
 
// clock_t start = clock();

int c[N], ans[N], la[N];
int tree[4 * N];

void upd(int pos, int val, int node, int st, int en) {
	if (st == en) {
		tree[node] = val;
		return;
	}
	int m = (st + en) / 2;
	if (pos <= m) upd(pos, val, 2*node+1, st, m);
	else upd(pos, val, 2*node+2, m+1, en);
	tree[node] = tree[2*node+1] + tree[2*node+2];
}
int qry(int l, int r, int node, int st, int en) {
	if (st > r || en < l) return 0;
	if (st >= l && en <= r) return tree[node];
	int m = (st + en) / 2;
	return qry(l, r, 2*node+1, st, m) + qry(l, r, 2*node+2, m+1, en);
}

void solve() {
	int n, q;
	cin >> n >> q;
	for (int i=1;i<=n;++i) {
		cin >> c[i];
		la[i] = 0;
	}
	for (int i=0;i<=4*n;++i) tree[i] = 0;
	vector<array<int, 3>> qu(q);
	for (int i=0;i<q;++i) {
		cin >> qu[i][0] >> qu[i][1];
		qu[i][2] = i;
	}
	sort(qu.begin(), qu.end(), [](array<int, 3> a, array<int, 3> b) {
		return a[1] < b[1];
	});
	int j = 0;
	for (int i=1;i<=n;++i) {
		int pre = la[c[i]];
		if (pre > 0) upd(pre, 0, 0, 1, n);
		la[c[i]] = i;
		upd(i, 1, 0, 1, n);
		while(j < q && qu[j][1] == i) {
			ans[qu[j][2]] = qry(qu[j][0], qu[j][1], 0, 1, n);
			++j;
		}
	}
	for (int i=0;i<q;++i) cout << ans[i] << '\n';
}
 
int main() {
	FASTIO;
	int T = 1;
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
	return 0;
} 

Measured memory_bytes: 23288