akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
#include <vector>
#include <set>
#include <map>

int main()
{
    while (true)
    {
        int n, x;
        std::cin >> n >> x;
        if (n == 0 && x == 0)
        {
            return 0;
        }
        int as = x - 3;
        if (as > n)
        {
            as = n;
        }
        int cIs = 0;
        for (int a = as; a > x / 3; a--)
        {
            int bs = x - a;
            if (bs >= a)
            {
                bs = a - 1;
            }
            for (int b = bs; b > (x - a) / 2; b--)
            {
                int cs = x - a - b;
                if (cs >= b)
                {
                    cs = b - 1;
                }
                if(cs >= 1)
                {
                    //std::cout << a << "+" << b << "+" << cs << "=" << x << "\n";
                    cIs += 1;
                }
            }
        }
        std::cout << cIs << "\n";
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long n, m, res;
int main() {
    DAU
    cin >> n >> m;
    res = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << res;
    PLEC
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   if(a == b){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i, a, b, c, count = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(i = a; i <= b; i++){
    if(c % i == 0){
    count++;
    }
  }
  printf("%d\n", count);
  return 0;
    }



Measured memory_bytes: 1992
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;

struct node {
	bool done;
	vi to, dist;
	int id, from;
	ll d;
	bool operator<(const node & another) const {
		return !(d != another.d ? d < another.d : id < another.id);
	}
};

void bellman_ford(vector<node> nodes, int n, int start, int limit) {
	nodes[start].d = 0;
	queue<node> que;
	que.push(nodes[start]);
	int cnt = 0;
	while (que.size()&&cnt<limit) {
		node focus = que.front(); que.pop();
		Loop(i, focus.to.size()) {
			if (nodes[focus.to[i]].d > focus.d + focus.dist[i]) {
				nodes[focus.to[i]].d = focus.d + focus.dist[i];
				nodes[focus.to[i]].from = focus.id;
				que.push(nodes[focus.to[i]]);
			}
		}
		cnt++;
	}
	if (cnt == limit) cout << "NEGATIVE CYCLE" << endl;
	else {
		Loop(i, n) {
			if (nodes[i].d == INFLL) cout << "INF" << endl;
			else cout << nodes[i].d << endl;
		}
	}
}

int main() {
	int v, e, r; cin >> v >> e >> r;
	vector<node> nodes(v + 5);
	Loop(i, v) nodes[i] = { false,{},{}, i, -1, INFLL };
	Loop(i, e) {
		int s, t, d; cin >> s >> t >> d;
		nodes[s].to.push_back(t);
		nodes[s].dist.push_back(d);
		/*
		nodes[t].to.push_back(s);
		nodes[t].dist.push_back(d);
		*/
	}
	bellman_ford(nodes, v, r, (v+1)*(e+1));
}

Measured memory_bytes: 3292
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<numeric>
using namespace std;
typedef long long int lli;
#define rep(i,n) for(lli i = 0;i<((lli)(n));i++)
#define reg(i,a,b) for(lli i = ((lli)(a));i<=((lli)(b));i++)
#define irep(i,n) for(lli i = ((lli)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(lli i = ((lli)(b));i>=((lli)(a));i--)
typedef pair<lli, lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprllif(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

lli n;

vector<lli> f(vector<lli> a){
	vector<lli> s(n+1);
	pque(lli) q;
		
	rep(i, n) q.push(a[i]);
	s[0] = accumulate(a.begin(), a.begin() + n, 0ll);
	
	rep(i, n){
		q.push(a[n+i]);
		s[i+1] = s[i] + a[n+i] - q.top();
		q.pop();
	}
	
	return s;
}

int main(void){
	cin >> n;
	vector<lli> a(n*3), b(n*3);
	rep(i, n*3) cin >> a[i];
	rep(i, n*3) b[i] = -a[3*n-1-i];
	
	auto s1 = f(a);
	auto s2	= f(b);

	lli ans = -LINF;
	rep(i, n+1) ans = max(ans, s1[i] + s2[n-i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10692
using System;
using System.Linq;

namespace ABC157B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a3 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            string res = "No";
            bool[] b1 = new bool[3];
            bool[] b2 = new bool[3];
            bool[] b3 = new bool[3];

            for (int i = 0; i < n; i++)
            {
                int b = int.Parse(Console.ReadLine());
                for (int j = 0; j < a1.Length; j++)
                {
                    if (a1[j] == b)
                    {
                        b1[j] = true;
                    }
                    if (a2[j] == b)
                    {
                        b2[j] = true;
                    }
                    if (a3[j] == b)
                    {
                        b3[j] = true;
                    }
                }
            }

            if (b1.All(e => e == true)|| b2.All(e => e == true)|| b3.All(e => e == true))
            {
                res = "Yes";
            }

            for (int i = 0; i < a1.Length; i++)
            {
                if (b1[i]&&b2[i]&&b3[i])
                {
                    res = "Yes";
                }
            }

            if (b1[0]&&b2[1]&&b3[2])
            {
                res = "Yes";
            }
            if (b1[2] && b2[1] && b3[0])
            {
                res = "Yes";
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
vector<int> v[100010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    set<int> s;
    int n;
    cin >> n;
    rep(i, n)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){


int A[3];

for(int i=0;i<3;i++) cin>>A[i];

sort(A,A+3);

cout<<A[0]<<' '<<A[1]<<' '<<A[2]<<endl;


return 0;

}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int H[110000];
signed main() {
    int m=0;
    cin>>N;
    for(int i=0;i<N;i++)cin>>H[i];
    int ans=0;
    for(int i=0;i<N;i++)if(H[i]>=m)m=H[i],ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];


signed main(){
	IOS();
	ll n, k;
	cin >> n >> k;
	ll h[114514];
	for (int i = 1;i <= n;++i) {
		cin >> h[i];
	}
	ll dp[114514];
	Fill(dp, INF);
	dp[1] = 0;
	for (int i = 1;i < n;++i) {
		for (int j = 1;i + j <= n && j <= k;++j){
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
	}
	cout << dp[n] << endl;
	
}

Measured memory_bytes: 1920
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


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



int main() {
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int A[101] = {};
	int B[101] = {};

	FOR(i, a+1, b + 1) {
		A[i] = 1;
	}
	FOR(i, c+1, d+1) {
		B[i] = 1;
	}
	int sum = 0;
	REP(i, 101) {
		if (A[i] == 1 && B[i] == 1) {
			sum++;
		}
	}
	ANS(sum);

	return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<int> hs(n);
    for(int i = 0; i < n; i++){
        cin >> hs[i];
    }
    sort(hs.rbegin(), hs.rend());
    auto solve = [&](int num){
        int cnt = num;
        for(int i = 0; i < n; i++){
            ll hp = hs[i] - b * num;
            if(hp <= 0){ break; }
            cnt -= (hp + a - b - 1) / (a - b);
            if(cnt < 0){
                break;
            }
        }
        return cnt >= 0;
    };
    int l = 0, r = 1e9;
    while(l < r){
        int piv = (l + r) / 2;
        if(solve(piv)){
            r = piv;
        }else{
            l = piv + 1;
        }
        prints(l, r);
    }
    cout << l << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define hh ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,c;
int main() {
	hh;
	cin>>a>>b>>c;
	if((c>=b&&c<=a)||(c<=b&&c>=a)) {
		printf("Yes");
	} else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
 
int main() {
  string s;
  cin >> s;
  int N = 0;
  N = s.size() - 1;
  ll ans = 0;
  ll num_s = stoll(s);
  
  rep(tmp, 1 << (N)) {
    if (tmp == 0) {
        continue;
    }
    bitset<9> k(tmp);
    int pre = -1;
    vector<ll> num_list;
    rep(i, N) {
      if (k[i] == 1) {
        string num_str = s.substr(N - i, i - pre);
        pre = i;
        num_list.push_back(stoll(num_str));
      }
    }
    num_list.push_back(stoll(s.substr(0, N - pre)));
    ans += accumulate(num_list.begin(), num_list.end(), 0);
  }
  printf("%lld\n", ans + num_s);
  return 0;
}

Measured memory_bytes: 3668
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    RH rh(S);

    // rolling_hash r(S);
    ll lv = 0, rv = N+1;
    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        bool ok = false;
        rep(i,0,N){
            rep(j,i+1,N){
                if(j - i < mid) continue;
                if(j+mid-1 >= N) continue;
                if(rh.get(i, i+mid) == rh.get(j, j+mid)){
                    ok = true;
                    break;
                }
            }
            if(ok) break;
        }
        if(ok){
            lv = mid;
        }else{
            rv = mid;
        }
    }
    print(lv);


    
}


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

int main (void){
  long long int max;
  vector<long long int> a(4,0);
  vector<long long int> b(4,0);

  for(int i = 0;i < 4;i++){
    cin >> a[i];
  }

  b[1] = a[0]*a[2];
  b[2] = a[0]*a[3];
  b[3] = a[1]*a[2];
  b[0] = a[1]*a[3];

max = b[0];
  for(int i = 1;i < 4;i++){
    if(b[i] >= max){
      max = b[i];
    }
  }
  cout << max << endl;
  return 0;

}


Measured memory_bytes: 3600
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int d;
    cin>>d;
    vector<int> c(26);
    rep(i,26)cin>>c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    /*
    vector<int> t(d);
    rep(i,d)cin>>t[i];
    */

    vector<int> last(26,0);
    ll score=0;
    rep(i,d){
        int m=0;
        int temp=0;
        rep(j,26){
            if(s[i][j]>=m)temp=j;
            m=max(m,s[i][j]);
        }
        last[temp]=i+1;
        cout<<temp+1<<endl;
        score+=m;
        rep(k,26){
            score-=(c[k]*(i+1-last[k]));
        }
    }
    score=max(1000000+score,(ll)0);
    //cout<<score<<endl;
            


}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int num = 1;
        for (int i = 0; i < N; i++) {
            num = Math.min(num * 2, num + K);
        }
        System.out.println(num);
    }
}


Measured memory_bytes: 21844
# include <cstdio>
# include <climits>
# include <vector>

using namespace std;

int main() {
  int n;
  vector<int> vec;
  for (int i = 0; i < 5; ++i) {
    scanf("%d", &n);
    vec.push_back(n);
  }
  int curr = 0;
  for (int i = 0; i < vec.size(); ++i) {
    if (vec[i] % 10 != 0) {
      if (vec[i] % 10 < vec[curr] % 10) {
        curr = i;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < vec.size(); ++i) {
    if (i != curr) {
      sum += vec[i];
      int rem = 0;
      if (vec[i] % 10 != 0) { rem = 10 - (vec[i] % 10); }
      sum += rem;
    } else {
      sum += vec[i];
    }
  }
  printf("%d", sum);
  fflush(stdout);
  return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n+10);
  for(int i = 0; i < n; ++i){
    int tmp;
    cin >> tmp;
    p[tmp] = i;
  }
  int cnt = 0;
  int m = 0;
  for(int i = 1; i < n; ++i){
    if(p[i] < p[i+1]){
      cnt++;
    }else{
      m = max(cnt, m);
      cnt = 0;
    }
  }
  if(m==0) m=cnt;
  cout << n - m - 1 << endl;
  return 0;
}

Measured memory_bytes: 1024
# Flipping Signs

N = int(input())
A = list(map(int, input().split()))
test = False

def answer(l):
    abs_l = []
    cnt_neg = 0

    for v in l:
        abs_l.append(abs(v))
        if v < 0:
            cnt_neg += 1  # 負数をカウント

    if test:
        print('abs_l  :', abs_l)
        print('cnt_neg:', cnt_neg)

    # 負の数が偶数個の時
    if cnt_neg % 2 == 0:
        return sum(abs_l)

    # 負の数が奇数個の時
    return sum(abs_l) - 2 * min(abs_l)


def main():
    print(answer(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
   long long int n;
   cin>>n;
   vector<string> hoge(n);
   for(long long int i=0; i<n; i++){
     cin>>hoge.at(i);
   }
   map<string,long long int> huga;
   huga[hoge.at(0)]++;
   char last=hoge.at(0)[hoge.at(0).size()-1];
   bool ok=true;
   for(long long int i=1; i<n; i++){
     if(huga.count(hoge.at(i))){
       ok=false;
       break;
     }
     huga[hoge.at(i)]++;
     if(last!=hoge.at(i)[0]){
       ok=false;
       break;
     }
     last=hoge.at(i)[hoge.at(i).size()-1];
   }
   if(ok){
     cout<<"Yes"<<endl;
   }else{
     cout<<"No"<<endl;
   }
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int N,buff,A,B;
  cin >> N;

  if(N == 1){
    cout << "Hello World" << endl;
  }
  else if(N == 2){
    cin >> A >> B;
    cout << A+B << endl;
  }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;

long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int t;
  cin>>t;
  rep(i,t){
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    cout<<floor_sum(n,m,a,b)<<'\n';
  }
  return(0);
}

Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int a,b,n;
  cin>>a>>b;
  n=(a+b)/2;
  if(abs(a-n)==abs(b-n))
  {
      cout<<n;
  }
  else
  {
      cout<<"IMPOSSIBLE";
  }





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int N;
	cin >> N;
	v.resize(N);
	vector<ll> wll(N + 1, 0);
	rep(i, 0, N - 1) {
		cin >> v[i];
		wll[i + 1] = wll[i] + v[i];
	}
	ll ans = 0;
	rep(i, 0, N - 1) {
		ll sum = (wll[N] - wll[i + 1]) % MOD;
		ans += v[i] * sum;
		ans %= MOD;
	}
	cout << ans << '\n';

}

Measured memory_bytes: 5616
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val q = sc.nextLong()
  val h = sc.nextLong()
  val s = sc.nextLong()
  val d = sc.nextLong()
  val n = sc.nextLong()

  val qp = 4 * q
  val hp = 2 * h
  val qh = Math.min(qp, hp)
  val min = Math.min(qh, s)

  val ans = mutableListOf<Long>()

  val case1 = n * min
  ans.add(case1)
  
  var tmpN = 0L
  if (n % 2L != 0L) {
    tmpN = 1L
  }
  val case2 = n / 2L * d + tmpN * min
  ans.add(case2)

  println(ans.min())
}

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

int main() {
  int n;

  cin >> n;

  // vector<int> a(n);

  double ans = 0;

  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    ans += 1 / a;
  }

  cout << 1 / ans;

  return 0;
}

Measured memory_bytes: 384
def main():
    x, y = map(int, input().split())
    for i in range(x+1):
        j = x - i
        if i*4 + j*2 == y:
            print("Yes")
            exit()
        if i*2 + j*4 == y:
            print("Yes")
            exit()
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);
        
    public static void main(String[] args) {
        String s = sc.nextLine();
        String ans = s;
        if(s.charAt(s.length()-1) == 's'){
            ans = ans + "es";
        }else{
            ans = ans + "s";
        }
        System.out.println(ans);
    }
}

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

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var valueList = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			var answer = 0;

			for(int i = 0;i < valueList.Count(); i++)
			{
				if(valueList[i] == 0)
				{
					answer = i + 1;
				}
			}

			Console.WriteLine(answer);
		}
	}
}

Measured memory_bytes: 28020
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define PI acos(-1)
using namespace std;

struct Point {
    double x;
    double y;
};


void f(Point p1, Point p2, int n) {
    if (n == 0) return;
    double theta = PI/3;
    Point s = {(2*p1.x + p2.x) / 3,(2*p1.y + p2.y) / 3};
    Point t = {(2*p2.x + p1.x) / 3,(2*p2.y + p1.y) / 3};
    Point u = {(t.x - s.x) * cos(theta) - (t.y - s.y) * sin(theta) + s.x,
               (t.x - s.x) * sin(theta) + (t.y - s.y) * cos(theta) + s.y};

    f(p1, s, n - 1);
    cout << s.x << " " << s.y << "\n";
    f(s, u, n - 1);
    cout << u.x << " " << u.y << "\n";
    f(u, t, n - 1);
    cout << t.x << " " << t.y << "\n";
    f(t, p2, n - 1);
}

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

    int n;
    cin >> n;
    cout << fixed << setprecision(8);
    cout << 0 << " " << 0  << "\n";
    f({0, 0}, {100, 0}, n);
    cout << "100" << " " << 0 << "\n";
    return 0;
}


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

using namespace std;
using ll = long long;

const int MAX_N = 100005;

int n,m,A[MAX_N];
map<int, pair<ll, ll>> sum;

// x[a..b]++ und add[a..b] += c
void magic(int a, int b, int c)
{
	if (a > b)
		return;
	sum[a].first++;
	sum[b+1].first--;
	sum[a].second += c;
	sum[b+1].second -= c;
}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=n; i++)
		scanf("%d",A+i);
	ll cost = 0;
	for (int i=1; i<n; i++)
	{
		int a = A[i], b = A[i+1];
		cost += (b-a+m)%m;
		if (a <= b)
			magic(a+1, b, -a-1); // a < x <= b: x - a - 1
		else
		{
			magic(a+1, m, -a-1); // a < x <= m:  x - a - 1
			magic(1, b, m-a-1);  // 1 <= x <= b: m - a + x - 1
		}
	}
	ll sub = 0, px = 0, padd = 0;
	for (auto it : sum)
	{
		sub = max(sub, (it.first-1)*px + padd);
		px += it.second.first;
		padd += it.second.second;

	}
	printf("%lld\n", cost - sub);
	return 0;
}

Measured memory_bytes: 6400
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 50;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}


int main(void){
 
  ll n;
  cin>>n;

  vector<ll> a(n);
  REP(i, n){
    ll x;
    cin>>x;
    a[i] = x;
  }
  sort(a.begin(), a.end());

  vector<ll> sum(n);
  sum[0] = a[0];
  FOR(i, 1, n-1) sum[i] = sum[i-1] + a[i];

  ll ans = 1;
  for(int i=n-2;i>=0;i--){
    if(a[i]*2>=a[n-1]) ans++;
    else{
      if(sum[i]*2>=a[i+1]) ans++;
      else i = -1;
    }
  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
def readinput():
    n=int(input())
    d=list(map(int,input().split()))
    return n,d

def power(x,n,MOD):
    res=1
    if n>0:
        res=power(x,n//2,MOD)
        if (n%2==0):
            res=(res*res)%MOD
        else:
            res=(((res*res)%MOD)*x)%MOD
    #print(x,n,MOD,res)
    return res

def main(n,d):
    MOD=998244353
    hist=[0]*(n+1)
    maxd=0
    for i in range(n):
        hist[d[i]]+=1
        maxd=max(maxd,d[i])
    #print(hist,maxd)

    ans=1
    if hist[0]>1:
        return 0
    if d[0]!=0:
        return 0
    for i in range(1,maxd+1):
        #print(i, hist[i-1], hist[i])
        ans=(ans*power(hist[i-1], hist[i], MOD))%MOD
        #print(ans)

    return ans

if __name__=='__main__':
    n,d=readinput()
    ans=main(n,d)
    print(ans)


Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        s[i] = (s[i]+n);
        if(s[i]>'Z'){
            s[i] = 'A' + (s[i]-'Z'-1);
        }
    }
    cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using namespace std;

const int N = 101;
int n;
int a[N];
bool u[N];

int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	vector<int> answer;
	for (int iter = 0; iter < n; ++iter) {
		for (int i = n; i >= 1; --i) {
			if (u[i]) {
				continue;
			}
			int p = accumulate(u, u + i, 0);
			if (a[i] == p + 1) {
				answer.push_back(i);
				u[i] = true;
				break;
			}
		}
	}
	if ((int)answer.size() == n) {
		for (int e : answer) {
			cout << a[e] << "\n";
		}
	} else {
		cout << "-1\n";
	}
	return 0;
}


Measured memory_bytes: 256
from bisect import *
from itertools import *
N,M,K = map(int,input().split())
A = [0]+list(accumulate(map(int,input().split())))
B = [0]+list(accumulate(map(int,input().split())))
ans = [0]

for n in range(1+N):
  C = bisect_right(B,K-A[n])-1
  if C!=-1:
    ans+=[C+n]

print(max(ans))

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

bool check(int n, int k, vector<int>& a, vector<int>& b, int m) {
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] * b[i] <= m) continue;
		int x = (a[i] * b[i] - m + b[i] - 1) / b[i];
		res += x;
	}
	return res <= k;
}

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	sort(rall(a));
	sort(all(b));

	int l = -1;
	int r = INF;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		if (check(n, k, a, b, m)) r = m;
		else l = m;
	}
	cout << r;
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

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

typedef pair <int, int> ii;

const int Maxn = 200005;
const int Maxm = 1048576;
const int Inf = 1000000000;

int n;
int b[Maxn];
int cnt[Maxn];
int q;
ii seq[Maxn];
int dp[Maxn];
int st[Maxm];

int Get(int l, int r) { return cnt[r] - cnt[l - 1]; }

void Clear(int v, int l, int r)
{
	st[v] = Inf;
	if (l < r) {
		int m = l + r >> 1;
		Clear(2 * v, l, m); 
		Clear(2 * v + 1, m + 1, r);
	}
}

int Get(int v, int l, int r, int x)
{
	int res = st[v] - Get(x, r);
	if (l < r) {
		int m = l + r >> 1;
		if (x <= m) res = min(res, Get(2 * v, l, m, x));
		else res = min(res, Get(2 * v + 1, m + 1, r, x));
	}
	return res;
}

void Insert(int v, int l, int r, int a, int b, int val)
{
	if (l == a && r == b) st[v] = min(st[v], val);
	else {
		int m = l + r >> 1;
		if (b <= m) Insert(2 * v, l, m, a, b, val);
		else if (m + 1 <= a) Insert(2 * v + 1, m + 1, r, a, b, val);
		else {
			Insert(2 * v, l, m, a, m, val - Get(m + 1, b));
			Insert(2 * v + 1, m + 1, r, m + 1, b, val);
		}
	} 
}

bool Less(const ii &a, const ii &b)
{
	return a.second < b.second;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		cnt[i] = cnt[i - 1] + (b[i] == 0);
	}
	Clear(1, 1, n);
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
		scanf("%d %d", &seq[i].first, &seq[i].second);
	sort(seq, seq + q, Less);
	int pnt = 0;
	dp[1] = 0;
	for (int i = 2; i <= n + 1; i++) {
		dp[i] = dp[i - 1] + (b[i - 1] == 1);
		while (pnt < q && seq[pnt].second + 1 == i) {
			int cand = min(dp[seq[pnt].first], Get(1, 1, n, seq[pnt].first)) + Get(seq[pnt].first, seq[pnt].second);
			Insert(1, 1, n, seq[pnt].first, seq[pnt].second, cand);
			dp[i] = min(dp[i], cand);
			pnt++;
		}
	}
	printf("%d\n", dp[n + 1]);
	return 0;
}

Measured memory_bytes: 8320
function main(input) {
	var lines = input.split("\n");
	var problemCount = parseInt(lines.shift());
	lines = lines.slice(0, problemCount);
	for (var i = 0; i < lines.length; i++) {
		var sides = lines[i].split(" ").slice(0,3)
		.map(function(value) {
			return parseInt(value);
		})
		.sort(function (a, b) {
			return a - b;
		});
		if(!isNaN(sides[0] && !isNaN(sides[1]) && !isNaN(sides[2]))) {
			console.log((Math.pow(sides[2],2) === Math.pow(sides[1],2) + Math.pow(sides[0],2)) ?
				'YES' :
				'NO');
		}
	}
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 17880
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int n, a[250001], dis[501][501], dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
bool f[501][501];
void bfs(int x, int y)
{
    queue<pair<int, int> > q;
    q.push(make_pair(x, y));
    while (!q.empty())
    {
        pair<int, int> tmp = q.front();
        q.pop();
        int xx = tmp.first, yy = tmp.second;
        for (int i = 0; i < 4; i++)
        {
            int tx = xx + dx[i], ty = yy + dy[i];
            if (tx < 1 || tx > n || ty < 1 || ty > n || dis[xx][yy] + f[xx][yy] >= dis[tx][ty])
            {
                continue;
            }
            dis[tx][ty] = dis[xx][yy] + f[xx][yy];
            q.push(make_pair(tx, ty));
        }
    }
}
int main(int argc, char const *argv[])
{
    scanf("%d", &n);
    for (int i = 1; i <= n * n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            dis[i][j] = min(min(i - 1, j - 1), min(n - i, n - j));
            f[i][j] = 1;
        }
    }
    long long ans = 0;
    for (int i = 1; i <= n * n; i++)
    {
        int x = (a[i] - 1) / n + 1, y = a[i] % n ? a[i] % n : n;
        ans += dis[x][y];
        f[x][y] = 0;
        bfs(x, y);
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 5868
int main(void){
	int n, count, i;
    int in[19];
  
	scanf("%d", &n);
    scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &in[0], &in[1], &in[2], &in[3], &in[4], &in[5], &in[6], &in[7], &in[8], &in[9], &in[10], &in[11], &in[12], &in[13], &in[14], &in[15], &in[16], &in[17], &in[18], &in[19]);
	for( i = 1; i < n-1; i++){
		
		if(in[i-1]<in[i]&&in[i]<in[i+1]){
			count++;
		}
      else if(in[i+1]<in[i]&&in[i]<in[i-1]){
			count++;
		};
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	double X = 100000;
	cin >> N;
	for (int i = 0; i < N; i++) {
		X *= 1.05;
		if (X != (long long)(X / 1000) * 1000) X = (long long)(X / 1000) * 1000 + 1000;
	}
	printf("%.0lf\n", X);
}


Measured memory_bytes: 3124
import Data.List

ans :: [[Int]] -> [String]
ans ([0,0,0]:_) = []
ans (s@[d,w,h]:[n]:x) =
  let d = take n x
      r = drop n x
      [a,b] = take 2 $ sort s
      o = map (\[r] -> if (2*r)^2 > a*a + b*b
                       then "OK"
                       else "NA" ) d
  in
    o++(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ putStrLn o

Measured memory_bytes: 4020
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
//ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<long long int> pq;
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
map<ll,ll> mp;



int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    //string s,s1;
    //char now,pre,c;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>a1>>a2;
        mp[a1]+=a2;
    }
    for(auto au:mp)
    {
        if(m>au.second)m-=au.second;
        else
        {
            cout<<au.first;
            break;
        }
    }
    return 0;
}





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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// トポロジカルソート
int n, m;
const int max_n = 1e5 + 10;

vector<int> g[max_n];
bool used[max_n];

vector<int> v;

void dfs(int u){
	if(used[u]) return;
	used[u] = true;
	for(int i: g[u]) dfs(i);
	//帰りがけ順で追加
	v.push_back(u);
}

void tsort(){
	for(int i = 0; i < n; i++) dfs(i);
	reverse(v.begin(), v.end());
}

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

	cin >> n >> m;
	rep(i, m){
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		g[x].push_back(y);
	}

	tsort();
	reverse(v.begin(), v.end());

	// cout << "tsort--";
	// rep(i, n) cout << " " << v[i];
	// cout << endl;

	// dp[i] : トポロジカルソートで頂点iより後ろのパスの最大長
	vector<int> dp(n, 0);
	int ans = 0;
	for(int i: v){
		for(int u : g[i]){
			// cout << i << " " << u << " " << dp[i] << " " << (dp[u]+1) << endl;
			dp[i] = max(dp[i], dp[u] + 1);
		}
		ans = max(ans, dp[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 8824
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

int c[510][510];
int s[510][510];

signed main(){
    int n,m,q;
    cin>>n>>m>>q;
    rep(i,m){
        int l,r;
        cin>>l>>r;
        c[l][r]++;
    }
    for(int i=1;i<=500;i++){
        for(int j=0;j<=500;j++){
            s[i][j+1]=s[i][j]+c[i][j];
        }
    }
    while(q--){
        int p,q;
        cin>>p>>q;
        int ans=0;
        for(int i=p;i<=q;i++) ans+=s[i][q+1]-s[i][p-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {

	int N, W;
	cin >> N >> W;
	vector<int> v(N), w(N);
	for (int i = 0; i < N; i++)cin >> v[i] >> w[i];

	int dp[110][10010];
	for (int i = 0; i <= W; i++)dp[0][i] = 0;//0個選んだ時の最大値は0

	for (int i = 0; i < N; i++) {//i個目まで
		for (int j = 0; j <= W; j++) {//重さj以下
			if (w[i] <= j)dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			else dp[i + 1][j] = dp[i][j];
		}
	}

	cout << dp[N][W] << endl;

	return 0;
}


Measured memory_bytes: 7080
#include<iostream>
using namespace std;
int main(){
	int takasa[10];
	for(int i=0;i<10;i++){
		cin>>takasa[i];
	}
	for(int i=0;i<9;i++){
		for(int j=i+1;j<10;j++){
			if(takasa[i]<takasa[j]){
				swap(takasa[i],takasa[j]);
			}
		}
	}



	for(int i=0;i<3;i++){
		cout<<takasa[i]<<endl;
	}





	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <string>
#include <math.h>
#include <iomanip>

class Vec2 {
public:
	double x;
	double y;

	
	Vec2(int tx, int ty)
	{
		x = tx;
		y = ty;
	}
};

Vec2 rot(const Vec2& vec, double r)
{
	Vec2 t(0,0);
	t.x = vec.x * cos(r) + vec.y * -sin(r);
	t.y = vec.x * sin(r) + vec.y * cos(r);
	return t;
}

const double PI = 3.1415926535;

using namespace std;

int main(void)
{
	int a, b, h, m;
	
	cin >> a >> b >> h >> m;

	Vec2 hour(0, a);
	Vec2 min(0, b);

	Vec2 ansHour = rot(hour, 2 * PI / 12.0 * (h + m/60.0) );
	Vec2 ansMin = rot(min, 2 * PI / 60.0 * m);

	double ans = (ansHour.x - ansMin.x) * (ansHour.x - ansMin.x) + (ansHour.y - ansMin.y) * (ansHour.y - ansMin.y);

	cout << std::fixed << std::setprecision(15) << sqrt(ans) << endl;

	return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll x,y,w,h,a,b,c,d,ans;
int main(void){
    cin>>x>>y>>w>>h>>a>>b>>c>>d;
    ll i=max(x,a),j=min(x+w,a+c),k=max(y,b),l=min(y+h,b+d);
    ans=w*h+c*d;
    if(i<j&&k<l)ans-=(j-i)*(l-k)*2LL;
    cout<<ans<<endl;
}



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

// bitの右からi+1番目が1かどうか
bool isBitI1(int bit, int i){
    return ((bit >> i) & 1) == 1;
}

int main(){
    int D,G;
    cin >> D >> G;

    int p[D], c[D];
    for(int i = 0; i<D; i++){
        cin >> p[i] >> c[i];
    }

    int min = 123456;
    int total, solved, rem;
    for (int bit = 0; bit < (1 << D); bit++){
        total = 0;
        solved = 0;
        for(int i = 0; i < D; i++){
            if(isBitI1(bit, i)){
                total += (i+1)*100 * p[i] + c[i];
                solved += p[i];
            }
        }

        if(total >= G && min > solved){
            min = solved;
            continue;
        }
        rem = G - total;

        for(int i = D-1; i >= 0; i--){
            if(!isBitI1(bit, i)){

                for(int j=0; j<p[i]-1; j++){
                    rem -= (i+1)*100;
                    solved ++;

                    if(rem <= 0 && min >= solved){
                        min = solved;
                        continue;
                    }
                }
            }
        }
    }

    cout << min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
struct Point{
   ll x,y;
   Point (ll x=0, ll y=0):x(x),y(y){}
};
 
typedef Point Vector;
 
Vector operator +(Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y); }
Vector operator -(Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
Vector operator *(Vector A,double p) { return Vector(A.x*p,A.y*p); }
 
ll Dot(Vector A,Vector B) { return A.x*B.x+A.y*B.y; }
ll Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; }
ll Length(Vector A) { return Dot(A,A); }
 
const int maxn = 2e5+10;
Point p[maxn],sol[maxn];
ll n,m;
 
bool cmp(Point a, Point b){
   ll ans = Cross(a-p[0],b-p[0]);
   return ans>0 || ans==0 && Length(a-p[0])<Length(b-p[0]);
}
 
ll ConvexHull(Point *p,Point *ch){
    sort(p+1,p+n,cmp);
    ll m = 0;
    for (ll i=0; i<n; i++) {
        while (m>1 && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
        ch[m++] = p[i];
    }
 
    ll k = m;
    for (ll i=n-2; i>=0; i--){
        while (m>k && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
        ch[m++] = p[i];
    }
 
    if (n>1) m--;
    return m;
}
ll f(Point A,Point B){
	return abs(A.x-B.x)+abs(A.y-B.y);
}
ll Rotate_calipers(Point* ch, int n){
    ll q=1;
    ll ans = 0;
    ch[n] = ch[0];
    for (ll i=0; i<n; i++) {
        while ( Cross(ch[q+1]-ch[i],ch[q+1]-ch[i+1])>Cross(ch[q]-ch[i],ch[q]-ch[i+1]) ) q = (q+1)%n;
        ans = max( ans,max( f(ch[i],ch[q]),f(ch[i+1],ch[q+1]) ) );
        //ans = max( ans,max( Length(ch[i]-ch[q]),Length(ch[i+1]-ch[q+1]) ) );
    }
    return ans;
}
 
int main(){
    while (scanf("%lld",&n)==1){
        ll x,y;
        for (ll i=0; i<n; i++) {
            scanf("%lld%lld",&x,&y);
            p[i] = Point(x,y);
        }
 
        if (n==2) {
            printf("%lld\n",f(p[0],p[1]));
            continue;
        }
 
        for (ll i=1; i<n; i++) {
            if (p[i].x<p[0].x || p[i].x==p[0].x && p[i].y<p[0].y) swap(p[i],p[0]);
        }
 
        //sort(p+1,p+n,cmp);
        //for (int i=0; i<n; i++) printf("%d %d\n",p[i].x,p[i].y);
 
        m = ConvexHull(p,sol);
        //printf("%d\n",m);
        printf("%lld\n",Rotate_calipers(sol,m));
 
    }
    return 0;
}

Measured memory_bytes: 7984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n, m;
  cin >> n >> m;
  vec1 a(m);
  ll b = 0;
  for(int i = 0; i < m; i++) {
    cin >> a.at(i);
    b = b + a.at(i);
  }
  if(b <= n) {
    cout << n-b << endl;
  } else {
    cout << "-1" << endl; 
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  vector<ll> ans(N);
  vector<bool> inserted(N);
  REP(i, 0, N) {
    bool ok = false;
    for (ll j = N - 1; j >= 0; j--) {
      if (!inserted[j]) {
        ll cnt = 0;
        for (ll k = j - 1; k >= 0; k--) {
          if (inserted[k]) cnt++;
        }
        if (cnt == A[j] - 1) {
          inserted[j] = true;
          ans[i] = A[j];
          ok = true;
          break;
        }
      }
    }
    if (!ok) {
      cout << -1 << endl;
      return 0;
    }
  }

  REP(i, 0, N) cout << ans[i] << endl;
}

Measured memory_bytes: 256