akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%M;

        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}
int maxSubArraySum(int a[], int size)
{
    int max_so_far = INT_MIN, max_ending_here = 0;

    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}

void solve()
{
int n;
cin>>n;
int a[n],b[n];
for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
sort(a,a+n);
sort(b,b+n);
int x,y;
if(n%2==0)
{
    x=a[n/2]+a[(n/2)-1];
    y=b[n/2]+b[(n/2)-1];
}
else
{
    x=a[n/2];
    y=b[n/2];
}
cout<<y-x+1<<endl;
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{

solve();

}
}


Measured memory_bytes: 6764
N = int(input())
K = int(input())
A = 0
if N <= 100000:
    for i in range(1,N+1):
        c = str(i)
        d = len(c) - c.count('0')
#    print(i,c,d,len(c),c.count('0'))
        if d == K:
            A += 1
else:
    keta = len(str(N))
    if K ==1:
        A = 9*(keta-1)
    if K ==2:
        A = 9*9*(keta-1)*(keta-2)//2
    if K ==3:
        A = 9*9*9*(keta-1)*(keta-2)*(keta-3)//6
    nc = 1
#    print(N,K,keta,A)
    while nc <= 3 and keta >=1:
        # abcd... -> 1000000 - a0000000
        T = N//(10**(keta-1))%10
#        print(T,nc)
        if T == 0:
            keta -=1
        else:
            if (nc == 1 and K==1) or (nc==2 and K==2) or (nc==3 and K==3):
              A = A + (T)
            if ((nc == 1 and K ==2) or (nc ==2 and K==3)):
                A = A + int((T-1)*9*(keta-1))
            if (nc==2 and K==2) or (nc==3 and K==3):
                A = A + 9*(keta-1)
            if (nc==1 and K ==3):
                A = A + int((T-1)*9*9*(keta-1)*(keta-2)/2)
            if (nc==2 and K==3):
                A = A + int(9*9*(keta-1)*(keta-2)/2)
            nc +=1
            keta -=1
#        print(A)
        
print(A)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


const LLI INF = 1000000000000000000;

int64_t ceil(int64_t a, int64_t b){
  if((a <= 0 and b < 0) or (a >= 0 and b > 0)) return (abs(a) + abs(b) - 1) / abs(b);
  return - (abs(a) / abs(b));
}

int64_t floor(int64_t a, int64_t b){
  if((a <= 0 and b < 0) or (a >= 0 and b > 0)) return a / b;
  return - (abs(a) + abs(b) - 1) / abs(b);
}


int main(){
  LLI N, K;
  while(cin >> N >> K){
    vector<LLI> A(N); cin >> A;
    sort(ALL(A));

    auto check =
      [&](LLI v){
        LLI c = 0;

        for(auto &x : A){
          if(x == 0){
            if(v >= 0) c += N;
            continue;
          }
          
          if(x > 0){
            LLI t = floor(v, x);
            
            c += upper_bound(ALL(A), t) - A.begin();

          }else if(x < 0){
            LLI t = ceil(v, x);

            c += N - (lower_bound(ALL(A), t) - A.begin());
          }
        }

        for(auto &x : A){
          if(x * x <= v) --c;
        }

        c /= 2;

        return c >= K;
      };
    
    LLI lb = -INF - 100, ub = INF + 100;
    while(abs(lb-ub) > 1){
      auto mid = (lb + ub) / 2;

      if(check(mid)){
        ub = mid;
      }else{
        lb = mid;
      }
    }

    puts_all(ub);
  }

  return 0;
}


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

using namespace std;
bool ip(const string& s, int left, int right) {
  for (int i = left; i < right; ++i) {
    if (s[i] != s[right - i - 1]) return false;
  }
  return true;
}
  
int main() {
  string s;
  cin >> s;
  int n(s.length());
  cout << (ip(s, 0, n) && ip(s, 0, n / 2) && ip(s, n/2+1, n) ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
//#define _XCODE_DEBUG

#include <iostream>
#include <string>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

int main() {
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    
    std::string S, T;
    std::cin >> S >> T;
    int ls = (int)S.length();
    int lt = (int)T.length();
    
    std::string ans = "";
    for (int i=0; i<ls-lt+1; ++i) {
        std::string str = S;
        int c = 0;
        for (int j=0; j<lt; ++j) {
            if (S.substr(i+j,1)==T.substr(j,1)) {
                ++c;
            }
            else if (S.substr(i+j,1)=="?") {
                str.replace(i+j, 1, T.substr(j,1));
                ++c;
            }
            else {
                break;
            }
        }
        if (c==lt) {
            ans = str;
            for (int i=0; i<ls; ++i) {
                int ind = (int)ans.find("?");
                if (ind==std::string::npos) break;
                else ans.replace(ind, 1, "a");
            }
        }
    }
    if (ans.length()) std::cout << ans << "\n";
    else std::cout << "UNRESTORABLE" << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

string s;

inline bool is_palindrome(string s) {
    return equal(s.begin(), s.end(), s.rbegin());
}

bool solve() {
    int n = s.size();
    return is_palindrome(s) && is_palindrome(s.substr(0, (n-1)/2)) && is_palindrome(s.substr((n+1)/2, (n-1)/2));
}

void input() {
    cin >> s;
}

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

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

typedef pair<int, P> PP;

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    auto dist = make_vec(h, w, INF);
    queue<P> que1, que2; 
    dist[sy][sx] = 0;
    que1.emplace(sy, sx);
    while(!que1.empty())
    {
        auto [y, x] = que1.front();
        que1.pop();
        rep2(dy,-2,3) rep2(dx,-2,3)
        {
            int ny = y + dy;
            int nx = x + dx;
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(field[ny][nx] == '#') continue;
            if(abs(dy) + abs(dx) <= 1) //移動1を使う
            {
                if(chmin(dist[ny][nx], dist[y][x]))
                    que1.emplace(ny, nx);
            }
            else //移動2を使う
            {
                if(chmin(dist[ny][nx], dist[y][x] + 1))
                    que2.emplace(ny, nx);
            }
        }
        if(que1.empty()) swap(que1, que2);
    }

    int ans = dist[gy][gx];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    // cout << dist << endl;

    return 0;
}

Measured memory_bytes: 8652
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A,0);
    rep(i,A) cin>>a.at(i);
    vector<int> b(B,0);
    rep(i,B) cin>>b.at(i);
    vector<tuple<int,int,int>> c(M);
    int x,y,z;
    int ans=1000000;
    rep(i,M){
        cin>>x>>y>>z;
        x --,y--;
        ans =min(ans,a[x]+b[y]-z);
           }

    sort(all(a));
    sort(all(b));
    ans =min(ans,a[0]+b[0]);
    cout<<ans<<endl;
}

Measured memory_bytes: 2176
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    n=length(s)
    for i in 1:n
        st=s[1:n-i]
        len=length(st)
        if len%2==0 && st[1:div(len,2)]==st[div(len,2)+1:end]
            println(len)
            break
        end
    end
end
main()

Measured memory_bytes: 168900
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> h(n, vector<int>(n, -1));
	int a, x, y;
	for (int i = 0; i < n; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) {
			cin >> x >> y;
			x--;
			h[i][x] = y;
		}
	}

	vector<int> d(n);
	bool ok = false;
	int max = 0;
	int cnt = 0;
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			if (((i >> j) & 1) == 1) {
				d[j] = 1;
			}
			else {
				d[j] = 0;
			}
		}

		ok = true;
		cnt = 0;
		for (int j = 0; j < n; j++) {
			if (d[j]) {
				for (int k = 0; k < n; k++) {
					if (h[j][k] == -1) {
						continue;
					}
					if (h[j][k] != d[k]) {
						ok = false;
						//break;
					}
				}
			}
		}
		if (ok) {
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					cnt++;
				}
			}
			max = (max < cnt) ? cnt : max;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  bool isOK = abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d);
  if (isOK) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <regex>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main () {
    ll S, C;
    cin >> S >> C;
    ll ans = 0;
    if(2 * S <= C) {
        ans = S + (C - 2 * S) / 4;
    }else {
        ans = C / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    ll cnt = 0LL, ans = 0LL;
    repr(i, s.size()) {
        if(s[i] == 'W') ++cnt;
        else {
            ans += cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        //string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        string str = Console.ReadLine();
        int A = int.Parse(str);
        //int B = int.Parse(str[1]);

        //string[] strHeight = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        //string[] results = new string[N];

        for( int i = 1; i < 10; i ++ )
        {
            if( A % i == 0 )
            {
                int B = A / i;
                if( B >= 1 && B < 10)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }
}

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

int f(int n) {
  if (n % 2 == 0) {
    return n / 2;
  } else {
    return 3 * n + 1;
  }
}

int main() {
  int s;
  cin >> s;
  vector<int> a = {s};
  int ans = -1;
  for (int i = 0;; ++i) {
    a.push_back(f(a.at(i)));
    for (int j = a.size() - 2; j >= 0; --j) {
      if (a.back() == a.at(j)) {
        ans = a.size();
        break;
      }
    }
    if (ans != -1) {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
module practiceA
  sub Main(ByVal args() as String)
    	Dim arr(2) as string
    	arr=Split(Console.ReadLine())
    	Dim N As Integer = arr(0)
    
        Dim M As Integer = arr(1)
        Dim x As Integer = 0
        Dim kekka As Integer = 0
        Dim i As Integer

        For i = 1 To N
            x = (N - i)
            kekka = x + kekka
        Next

        For i = 1 To M
            x = (M - i)
            kekka = x + kekka
        Next

Console.WriteLine(kekka)

  end sub
end module

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

int main() {
    
    char c;
    
    cin >> c;
    if(c>='A' && c<='Z'){
        cout << "A" << endl;
    }
    else if(c>='a' && c<='z'){
        cout << "a" << endl;
    }
    
    
    
    
    
    
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

string s;
int main(void){
    cin >> s;
    int l = s.length();
    int count = 0;
    for (int i=0;i<l/2;i++){
        if(s[i] != s[l-i-1]) count++;
    }
    cout << count << endl;
    return 0;
}



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

sx = list(sorted(X))
m1 = sx[N//2 - 1]
m2 = sx[N//2]

ans = []
for a in X:
    if a >= m2:
        ans.append(m1)
    else:
        ans.append(m2)
print(*ans, sep='\n')

Measured memory_bytes: 25556
// Problem : C - Connect Cities
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll n,m;
	cin >> n >> m;
	vector<vector<int>> v(n);
	for(int i=0;i<m;++i)
	{
		int a,b;
		cin >> a >> b;
		--a;--b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> vis(n);
	int ans=0;
	for(int i=0;i<n;++i)
	{
		if(!vis[i])
		{
			ans++;
			queue<int> q;
			q.push(i);
			vis[i]=1;
			while(!q.empty())
			{
				int t=q.front();
				q.pop();
				for(int u:v[t])
				{
					if(!vis[u])
					{
						vis[u]=1;
						q.push(u);
					}
				}
			}
		}
	}
	cout << ans-1 << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 8748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

Graph G;
ll dp[100010];
ll N, M;

ll solve(ll v)
{
	if (dp[v] != -1) return dp[v];

	ll res{0};
	for (auto &nv : G[v])
	{
		res = max(res, solve(nv)+1);
	}
	return dp[v] = res;
}

int main(int argc, char **argv)
{
	cin >> N >> M;
	G.assign(N, vector<ll>());

	for (ll i = 0; i < M; ++i)
	{
		ll a, b; cin >> a >> b; --a, --b;
		G[a].push_back(b);
	}

	for (ll i = 0; i < N; ++i) dp[i] = -1;

	ll res{0};
	for (ll v = 0; v < N; ++v) res = max(res, solve(v));
	std::cout << res << std::endl;
}


Measured memory_bytes: 8576
#include<stdio.h>
#define NOT_FREE 1
#define FREE 0
#define N 8

void putqueen(int);
void printboard(void);

int row[N], col[N], dpos[2*N-1], dneg[2*N-1], Q[N][N];

int main(){
  int k, i, r, c, j;

  scanf("%d", &k);

  for(i = 0; i < k; i++){
    scanf("%d%d", &r, &c);
    Q[r][c] = NOT_FREE;
  }

  putqueen(0);

  return 0;
}

void putqueen(int i){
  int j;

  if(i == N){
    printboard();
    return;
  }

  for(j = 0; j < N; j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)
      continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    putqueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printboard(){
  int i, j;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(Q[i][j] == NOT_FREE){
	if(row[i] != j)
	  return;
      }
    }
  }

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }
}

Measured memory_bytes: 572
def sinsu(M,k):
    L=0
    MM=M
    while(True):
        L+=MM%k
        MM=MM//k
        if MM==0:
            break
    return L
N=int(input())
ans=N
for i in range(N+1):
    a=i
    b=N-i
    tmp=sinsu(a,6)+sinsu(b,9)
    if ans>tmp:
        ans=tmp
print(ans)


Measured memory_bytes: 3064
S = list(input())
N = len(S)
ans = 'No'
if S == S[::-1]:
    sub_1 = S[:(N - 1) // 2]
    if sub_1 == sub_1[::-1]:
        sub_2 = S[(N + 2) // 2:]
        if sub_2 == sub_2[::-1]:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

double R = 6378.1;

int calc(double[] d) {
    auto x1 = [cos(d[0]*PI/180)*cos(d[1]*PI/180), cos(d[0]*PI/180)*sin(d[1]*PI/180), sin(d[0]*PI/180)];
    auto x2 = [cos(d[2]*PI/180)*cos(d[3]*PI/180), cos(d[2]*PI/180)*sin(d[3]*PI/180), sin(d[2]*PI/180)];
    auto dot = zip(x1, x2).map!"a[0]*a[1]".sum;
    return round((R * acos(dot))).to!int;
}

void main(){
    while(true) {
        auto l = readln().chomp();
        if(l == "-1 -1 -1 -1") {
            return;
        }
        auto d = l.split(" ").map!(to!double).array;
        writeln(calc(d));
    }
}

Measured memory_bytes: 2664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

int N, D[55], b[55];
int cnt[55];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", D+i ), ++cnt[D[i]];

  int ans = 1;

  if( N >= 14 )
  {
    if( cnt[0] >= 1 || cnt[12] >= 2 )
      ans = 0;

    repi( i, 1, 12 ) if( cnt[i] >= 3 )
      ans = 0;
  }
  else
  {
    ans = 0;
    D[N] = 0;
    for( int i = 0; i <= (1<<14); ++i )
    {
      int mi = 1<<30;
      rep( j, N+1 )
        b[j] = D[j]+(i>>j&1?24-2*D[j]:0);

      rep( j, N+1 ) rep( k, N+1 ) if( j != k )
        mi = std::min( mi, std::min( abs(b[k]-b[j]), 24-abs(b[k]-b[j]) ) );

      ans = std::max( ans, mi );
    }
  }

  if( N == 1 )
    ans = std::min( D[0], 24-D[0] );

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<algorithm>
#include<cctype>
#include<vector>
#include<map>
#include<set>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
int main()
{
	int n,r;
	scanf("%d%d",&n,&r);
	if(n>=10)printf("%d\n",r);
	else printf("%d\n",r+100*(10-n));
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int f = 0, g = 0, h = 0;
  rep(i, 0, 3){
    char a;
    cin >> a;
    if(a == 'a') f++;
    else if(a == 'b') g++;
    else if(a == 'c') h++;
  }
  if(f == 1 && g == 1 && h == 1){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
}
  
  

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()


ll a = 0,ans = 0;
string s;

int main(){
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'S')a++;
		else {
			if (a == 0)ans++;
			else a--;
		}
	}
	ans += a;
	cout << ans << endl;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) ll(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<ll,ll>;
using Pl = pair<ll,ll>;
using vi = vector<ll>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const ll dx[] = {0,1,0,-1,1,1,-1,-1};
const ll dy[] = {1,0,-1,0,1,-1,-1,1};
const ll inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }


struct Sieve { // 篩
  ll n;
  vector<ll> f, primes;
  Sieve(ll n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(ll x) { return f[x] == x;} // 素数判定
  vector<ll> factorList(ll x) { // 素因数列挙
    vector<ll> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(ll x) { // 素因数分解(ランレングス圧縮的なもの)
    vector<ll> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (ll p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


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

  ll n;
  cin >> n;
  ll m = 0;
  while(m*m < n) m++;
  Sieve s(m);
  s.primes.push_back(n);
  ll idx = 0;
  map<ll, ll> mp;
  while(n > 1 && idx < sz(s.primes)) {
    if(n % s.primes[idx] == 0) {
      mp[s.primes[idx]]++;
      n /= s.primes[idx];
    }
    else idx++;
  }
  if(n != 1) mp[n]++;
  ll ans = 0;
  for(Pl p : mp) {
    ll cnt = 0;
    ll cur = 1;
    while(cnt + cur <= p.se) {
      cnt += cur;
      cur++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 12088
use std::char;
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    println!("{}", (n-1)/2+1)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a;
    cin >> a;
    if(a == 7 || a == 5 || a == 3) YES();
    else NO();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 100001
#define B -1
typedef struct {
  int  parent;
  int  left;
  int  right;
}BINARY;
  
BINARY A[N];
 
int depth(int);
int degree(int);
 
main(){
  int i,j,ch,sugiyama,id,de,l;
  scanf("%d", &sugiyama);
  for(i=0; i<sugiyama; i++)
    {
      A[i].parent = B;
      A[i].left = B;
      A[i].right = B;
    }
  //ここから
  for(i=0; i<sugiyama;i++)
    {
      scanf("%d%d",&id, &de);
      for(j = 0; j < de; j++)
	{
	  scanf("%d", &ch);
	  A[ch].parent = id;
	  if(j == 0)
	    {
	      A[id].left = ch;
	    }
	  else
	    {
	      A[l].right = ch;
	    }
	  l = ch;
	  
	}
    }
  
  for(i = 0; i < sugiyama; i++){
    printf("node %d: parent = %d, depth = %d, ", i, A[i].parent, depth(i));
    if(A[i].parent == B)
      {
	printf("root, [");
      }
    else if(A[i].left == B)
      {
	printf("leaf, [");
      }
    else
      {
	printf("internal node, [");
      }
    degree(A[i].left);
    printf("]\n");
  }
  return 0;
}

int depth(int d){
  int deep = 0;
  if(A[d].parent == B)
    {
      return 0;
    }
  else 
    {
      deep = depth(A[d].parent) + 1;
      return deep;
    }
}

int degree(int e){
  if(e == B)
    {
      return 0;
    }
  else 
    {
    if(A[e].right == B){
      printf("%d",e); 
    }
    else
      {
	printf("%d, ",e);
	degree(A[e].right);
      }
    }
}

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

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

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

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  scanf("%d", &n);
  int a[110000];
  int b[110000];
  int c[110000];

  rep(i, n) cin >> a[i] >> b[i] >> c[i];

  int dp[110000][3];

  rep(j, 3) dp[0][j] = 0;

  rep(i, n){
    rep(j, 3){
      if (j == 0) dp[i+1][j] = max(dp[i][1], dp[i][2]) + a[i];
      if (j == 1) dp[i+1][j] = max(dp[i][0], dp[i][2]) + b[i];
      if (j == 2) dp[i+1][j] = max(dp[i][0], dp[i][1]) + c[i];
    }
  }

  int mx = 0;


  rep(j, 3){
    mx = max(dp[n][j], mx);
  }

  printf("%d\n", mx);
}

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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    if(n % 1000 == 0) cout << 0 << "\n";
    else cout << 1000 - n % 1000 << "\n";

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

struct graph {
	
	int V;
	vector<int> *adj;
	
	graph(int x) {
		V = x;
		adj = new vector<int>[x];
	}
	
	void AddEdge (int a, int b) {
		
		adj[a].pb(b);
		adj[b].pb(a);
	}
};

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    
	int n, m, x, y;
	cin >> n >> m;
	
	int value[n];
	rep(i, n)
		cin >> value[i];
		
	graph g(n);
	
	rep(i, m) {
		
		cin >> x >> y;
		x--;
		y--;
		g.AddEdge(x, y);
	}	
	
	int count = 0;
	
	rep(i, n) {
		
		bool flag = true;
		
		for (auto it = g.adj[i].begin(); it != g.adj[i].end(); it++){
			
			if (*it != i && value[*it] >= value[i]) {
				flag = false;
				break;
			}
		}
		if (flag)
			count++;
	}
	
	cout << count << "\n";
	
	//code
	return 0;
}


Measured memory_bytes: 9196
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

import copy

def main():
	n=II()
	A=[]
	for _ in range(n):
		a=LI()
		A.append(a)

	for i in range(n):
		A[i][i]=10**10

	B=copy.deepcopy(A)

	for k in range(n):
		for i in range(n):
			for j in range(n):
				if i!=j:
					B[i][j]=min(B[i][j],B[i][k]+B[k][j])

	if A!=B:
		print(-1)
		exit(0)

	for k in range(n):
		for i in range(n):
			for j in range(n):
				if B[i][j]==B[i][k]+B[k][j]:
					A[i][j]=0

	ans=0

	for i in range(n):
		for j in range(i,n):
			if i!=j:
				ans+=A[i][j]

	print(ans)


if __name__ == "__main__":
	main()

Measured memory_bytes: 55516
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>

using namespace std;

int a;
string s;

int main(int argc, const char * argv[]) {
    
    /////////
    //write//
    /////////
    
    cin >> a >> s;
    
    if(a>=3200)cout << s;
    else cout << "red";
    cout << endl;
    
    return 0;
}


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

using namespace std;

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

    string S;
    cin >> S;

    bool isok[100005] = {};
    int a, b; // 国内の通過人数，海外の通過人数
    a = b = 0;

    for (int i = 0; i < N; ++i) {
        if (S[i] == 'a') {
            if (a + b < A + B) {
                isok[i] = true;
                a++;
            }
        } else if (S[i] == 'b') {
            if (a + b < A + B && b < B) {
                isok[i] = true;
                b++;
            }
        }
    }

    for (int i = 0; i < N; ++i)
        cout << (isok[i] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(void){
  int n;
  int m=0;
  bool f=false;
  cin>>n;
  vector<string> s(n);
  vector<int> a(n,1);
  rep(i,n){
    cin>>s[i];
  }
  sort(s.begin(), s.end());
  rep(i,n-1){
    if(s[i+1]==s[i]){
      if(f){
        a[m]++; a[i+1]--;
      }
      else{
        m=i;
        a[m]++; a[i+1]--;
        f=true;
      }
    }
    else{
      m=i;
      f=false;
    }
  }
  int ma=0;
  rep(i,n){
    ma=max(ma,a[i]);
  }
  rep(i,n){
    if(a[i]==ma){
      cout<<s[i]<<endl;
    }
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = (int) 100 + 10;
const int V = (int) 1e3 + 10;
const ll oo = 1e18;

int n, w;
pair<int, int> items[N];
ll memo[N][N * V];

ll dp(int at, int value) {
    if(value < 0) return oo;
    if(at == n) return value == 0 ? 0 : oo;
    ll &ans = memo[at][value];
    if(ans != -1) return ans;
    ll choose = items[at].first + dp(at + 1, value - items[at].second);
    ll skip = dp(at + 1, value);
    return ans = min(choose, skip);
}

void solve() {
    cin >> n >> w;
    for(int i = 0; i < n; ++i) {
        cin >> items[i].first >> items[i].second;
    }
    memset(memo, -1, sizeof(memo));
    ll ans = -oo;
    for(ll value = 0; value < N * V; ++value) {
        if(dp(0, value) <= w) {
            ans = max(ans, value);
        }
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 95744
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int n;
  cin>>n;
  n=n%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9)
  cout<<"hon"<<endl;
  else if(n==0 || n==1 || n==6 || n==8)
  cout<<"pon"<<endl;
  else
  cout<<"bon"<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3656
S = input()
N = len(S)
A = [-1 for i in range(N+1)]
if S[0] == "<":
  A[0] = 0
if S[-1] == ">":
  A[-1] = 0
  
for i in range(N):
  if S[i:i+2] == "><":
    A[i+1] = 0

#print(A)

for i in range(N):
  if S[i] == "<":
    A[i+1] = max(A[i]+1, A[i+1])
    
for i in range(N):
  if S[N-i-1] == ">":
    A[N-i-1] = max(A[N-i]+1, A[N-i-1])
    
#print(A)
print(sum(A))

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

int main() {
    int n, m;
    cin >> n >> m;

    int a;
    for (int i = 0; i < m; i++) {
        cin >> a;
        n -= a;
    }
    if (n < 0) {
        cout << -1 << endl;
    }
    else {
        cout << n << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	ll n, m, ans = 0;
	cin >> n >> m;
	vector<pair<ll, ll>> a(n);
	FOR(i, n)cin >> a[i].first >> a[i].second;

	SORT(a);
	FOR(i, n) {
		if (m > a[i].second) {
			ans += a[i].first*a[i].second;
			m -= a[i].second;
		}
		else if (m == a[i].second) {
			ans += a[i].first*a[i].second;
			cout << ans << endl;
			break;
		}
		else {
			ans += a[i].first*m;
			cout << ans << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int m = int.Parse(cin[1]);
        var basket = new int[m];
        for (int i = 0; i < n; i++)
        {
            int[] cin2 = Console.ReadLine().Split().Select(t => int.Parse(t)).ToArray();
            for (int j = 1; j < cin2.Length; j++)
            {
                basket[cin2[j] - 1]++;
            }
        }

        int ans = 0;
        for (int i = 0; i < m; i++)
        {
            if (basket[i] == n) ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

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

void print_vector(vector<ll> vt){
    for(auto v: vt){
        cout << v;
    }
    cout << endl;
}

int Q;
vector<ll> A(100), B(100);

int main()
{
    cin >> Q;
    for(int q=0; q<Q; q++){
        cin >> A[q] >> B[q];
    }
    for(int q=0; q<Q; q++){
        if(A[q]==B[q]) cout << 2*(A[q]-1) << endl;
        else {
            ll C=sqrt(A[q]*B[q]);
            ll D=(A[q]*B[q]-1)/C;
            cout << D+C-2 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**8)


S, stack = [], []
N = 0


def main() -> None:
    global N
    N, A, B, C = rmi()
    for n in range(N):
        S.append(r())
    enable = dfs(stack, 0, A, B, C)
    w('Yes' if enable else 'No')
    if enable:
        wm(*stack, delim='\n')


def dfs(stack, index, a, b, c) -> bool:
    if N <= index:
        return True
    inst = S[index]
    if inst == 'AB':
        if a <= 0 and b <= 0:
            return False
        if 0 < a:
            stack.append('B')
            result = dfs(stack, index + 1, a - 1, b + 1, c)
            if result:
                return True
            else:
                stack.pop()
        if 0 < b:
            stack.append('A')
            result = dfs(stack, index + 1, a + 1, b - 1, c)
            if result:
                return True
            else:
                stack.pop()
    elif inst == 'AC':
        if a <= 0 and c <= 0:
            return False
        if 0 < a:
            stack.append('C')
            result = dfs(stack, index + 1, a - 1, b, c + 1)
            if result:
                return True
            else:
                stack.pop()
        if 0 < c:
            stack.append('A')
            result = dfs(stack, index + 1, a + 1, b, c - 1)
            if result:
                return True
            else:
                stack.pop()
    else:
        if b <= 0 and c <= 0:
            return False
        if 0 < b:
            stack.append('C')
            result = dfs(stack, index + 1, a, b - 1, c + 1)
            if result:
                return True
            else:
                stack.pop()
        if 0 < c:
            stack.append('B')
            result = dfs(stack, index + 1, a, b + 1, c - 1)
            if result:
                return True
            else:
                stack.pop()
    return False


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 110892
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 3030;

int MOD;
int poly[ms];

void mul(int x) {
	for(int i = ms-1; i > 0; i--) {
		poly[i] = (poly[i-1] - x * poly[i] % MOD + MOD) % MOD;
	}
	poly[0] = (-poly[0] * x % MOD + MOD) % MOD;
}

void divid(int x) { 
	int rest = 0;
	for(int i = ms-1; i >= 0; i--) {
		int val = (poly[i] + x * rest) % MOD;
		poly[i] = rest;
		rest = val;
	}
	assert(rest == 0);
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::cin >> MOD;
	poly[0] = 1;
	for(int i = 0; i < MOD; i++) {
		mul(i);
	}
	std::vector<int> ans(MOD, 0);
	for(int i = 0; i < MOD; i++) {
		int ha;
		std::cin >> ha;
		if(ha == 0) continue;
		divid(i);
		for(int j = 0; j < MOD; j++) {
			ans[j] = (ans[j] + (MOD-1) * poly[j]) % MOD;
		}
		mul(i);
	}
	for(int i = 0; i < MOD; i++) {
		std::cout << ans[i] << (i+1==MOD?'\n':' ');
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
   char str[21];
   scanf("%s",str);
  int l=strlen(str);
   for(char* p=str+l-1;p>=str;p--)
      printf("%c",*p);
   printf("\n");
   return 0;

}

Measured memory_bytes: 932
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


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> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	int p = 0, cnt = 0;
	int ans = 0;
	REP(i, n) {
		if (p != v[i]) {
			ans += cnt/ 2;
			cnt = 1;
			p = v[i];
		}
		else {
			cnt++;
		}
	}
		ans += cnt / 2;
		cnt = 1;
		cout << ans << endl;
}

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

ll N, K;

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

	cin >> N >> K;
	lf ans = 0;
	for (ll i = 1; i <= N; i++) {
		lf cur = 1.0/N;
		for (ll j = i; j < K; j *= 2) {
			cur *= 0.5;
		}
		ans += cur;
	}

	cout << fixed << setprecision(12) << ans << "\n";
}

Measured memory_bytes: 256
n,Y=map(int,input().split())
ans=-1,-1,-1
for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    if x*10000+y*5000+z*1000==Y and 0<=z<=2000:
      ans=x,y,z
      break
  else:
    continue
  break
print(*ans)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i, j, x, y;
    cin >> i;
    j = i / 1000;
    x = i % 1000;
    if (x > 0)
    {
        j++;
        y = 1000 * j - i;
        cout << y << endl;
    }
    else
        cout << 0 << endl;
}

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

int main() {
    string S;
    cin >> S;
    int counter = 700;
    if (S[0] == 'o') counter = counter + 100;
    if (S[1] == 'o') counter = counter + 100;
    if (S[2] == 'o') counter = counter + 100;
    cout << counter << endl;
}

Measured memory_bytes: 256