akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll t(n);
  ll sumt = 0;
  REP(i, n) {
    cin >> t[i];
    sumt += t[i];
  }
  ll m; cin >> m;
  REP(_, m) {
    ll p, x; cin >> p >> x;
    cout << sumt - t[p-1] + x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

max_cnt = 0
for i in range(1, N):
    x = set(S[0:i])
    y = set(S[i:N])
    x_y = len(x & y)
    
    if x_y > max_cnt:
        max_cnt = x_y
        
print(max_cnt)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
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; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/
ll p(int a){
  ll b=1;
  rep(i,a) b*=10;
  return b;
}

int main() {

  ll n, m, count=0, ans=1;
  string s;
  cin >> n;
  bool zero=false,big=false;
  vector<ll> num(n);
  rep(i,n) cin >> num[i];
  sort( num.begin(), num.end());
  if(num[0]==0){
    cout << 0 << endl;
    return 0;
  }
  else{
    rep(i,n){
      rep2(l,18){
        if(ans>p(l)&&num[i]>p(18-l)){
          cout << -1 << endl;
          return 0;
        }
      }
      ans*=num[i];
      if(ans>p(18)){
        cout << -1 << endl;
        return 0;
      }
    }
    cout << ans << endl;
  }
  
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
void solve(void)
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,d[102],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>d[i];
	}
	sort(d+1,d+n+1);
	for(int i=n;i>=1;i--)
	{
		if(d[i]!=d[i+1])
		{
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
int main()
{	
	int a,b;
	char s[20];
	scanf("%s",s);
	for(int i = 0;i <= 18;i ++)
	{
		if(i != 5 && i != 13)printf("%c",s[i]);
		if(i == 5 || i == 13)printf(" ");
			
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#define LL long long
using namespace std;
const int M =1e6+5;
char s[M];
int main() {
    LL n;
    cin>>n;
    LL ans=n/11*2;
//    cout<<n%11<<endl;
    if(n%11) ans++;
    if(n%11>6) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n,f=-1,l=-1,al=0,af=0,r=0,w=0,rp=0;
string s;
cin>>n;
cin>>s;
for(int i=0;i<n;i++)
{
    if(s[i]=='W')
    {
        f=i;
        break;
    }
}
for(int i=0;i<n;i++)
{
    if(s[n-i-1]=='R')
    {
        l=n-i-1;
        break;
    }
}
for(int i=0;i<n;i++)
{
    if(s[i]=='R')
        r++;
    else
        w++;
}
for(int i=0;i<r;i++)
{
    if(s[i]=='R')
        rp++;
}
if(f==-1||l==-1)
    cout<<"0"<<"\n";
else
    cout<<r-rp<<"\n";

}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
//cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める

int main(){
    int n ;
    cin >> n; 
    vector<int> A(n);
    rep(i,n){
        cin>>A[i];
    }
    int count = 0;
    rep(i,n){
        int minj = i;
        for(int j = i ; j  < n ; j ++ ){
            //minjに最初の要素の位置を入れておく
            if(A[j]<A[minj]){
                minj = j;
            }
        }
        if (minj != i){
            swap(A[i], A[minj]);
            count++;
        }
    }
    rep(i,n){
        if(i!=n-1)cout<<A[i]<<" ";
        else cout<<A[i]<<endl;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=5+2*1e5;
const LL INF=1<<30;
int solve(){
	int n,k=0;
	cin >> n;
	n+=n;
	string s,s2;
	cin >> s >> s2;
	REP(i,s.size()+1){
		REP(j,i+1){
			if(j==i) k=i;
			else if(s[s.size()-i+j]!=s2[j]) break;	
		}
	}
	return n-k;
}
int main(){

	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N,max = 0, count,H1,H2;
    scanf("%d",&N);
    scanf("%d",&H1);
    count = 0;
    for(int i = 1; i < N; i++)
    {
        scanf("%d\n",&H2);
        if(H2 <= H1)
        {
            count++;
            if(max < count)
                max = count;
        }
        else
        {
            count = 0;
        }
        H1 = H2;        
    }
    printf("%d\n",max);
}


Measured memory_bytes: 128
#include <stdio.h>
int main() {
    int nStep;
    scanf("%d", &nStep);
    int prex =  0, prey = 0, pret = 0;
    while(nStep--) {
        int x, y, t;
        scanf("%d%d%d", &t, &x, &y);
        if(abs(x - prex) + abs(y - prey) > abs(t - pret) ||
            (abs(x - prex) + abs(y - prey)) % 2 != abs(t - pret) % 2 ){
            printf("No");
            return 0;
        }
        prex = x; prey = y; pret = t;
    }
    printf("Yes\n" );
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
input:
    ll a;
    cin >> a;
    cout << a * a << endl;

calculate:
    return 0;
}



Measured memory_bytes: 256
S = input()
N = len(S)
DP =[0]*13
DP[0] = 1
A = 0
MOD = 10**9+7

T = [1,10,9,12,3,4]
A = 0
for i in range(N):
    A*=10
    if S[i] == "?":
        hoge = [0]*13
        for j in range(13):
            for k in range(10):
                hoge[(j+k*T[(N-i-1)%6])%13] = (hoge[(j+k*T[(N-i-1)%6])%13] + DP[j])%MOD
        DP = hoge[:]
    else:
        A += int(S[i])
    A = A%13
print(DP[(5-A)%13])

Measured memory_bytes: 43756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;cin>>x;
	double base=100;
	ll ans=0;
	while(base<x){
		ans++;
		base=floor(base*(1.01));
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	while(n=in()){
		int i;
		int res=0;
		for(i=0;i<n;i++){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			if(x+y+h<=60&&w<=2)res+=600;
			else if(x+y+h<=80&&w<=5)res+=800;
			else if(x+y+h<=100&&w<=10)res+=1000;
			else if(x+y+h<=120&&w<=15)res+=1200;
			else if(x+y+h<=140&&w<=20)res+=1400;
			else if(x+y+h<=160&&w<=25)res+=1600;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S; cin>>S;
  vector<int> P(S.size());
    
  for(int i=0; i<S.size()-1; i++){
    if(S[i]=='R' && S[i+1]=='L'){
      int j=i;
      while(j>=0 && S[j]=='R'){
        if(abs(j-i)%2==0){
          P[i]++;
        }
        else{
          P[i+1]++;
        }
        j--;
      }
      j=i+1;
      while(j<S.size() && S[j]=='L'){
        if(abs(j-i)%2==0){
          P[i]++;
        }
        else{
          P[i+1]++;
        }
        j++;
      }
    }
  }
  for(int i=0; i<P.size(); i++){
    cout<<P[i]<<" ";
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

class CumulativeSum2D
{
private:
  vector< vector< int > > data;
public:
  CumulativeSum2D(int W, int H)
  {
      data = vector<vector<int>>(W+1,std::vector<int>(H + 1,0));
  };

  void add(int x, int y, int z)
  {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  int query(int sx, int sy, int gx, int gy)
  {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

int main(){
    CIN(N);CIN(M);CIN(Q);
    I L,R;
    CumulativeSum2D hoge(N+1,N+1);
    REP(a,M){
        CIN(b);CIN(c);
        hoge.add(b,c,1);
    }
    hoge.build();
    cout<<endl;
    REP(z,Q){
        CIN(b);CIN(c);
        COUT(hoge.query(b,b,c+1,c+1));
    }
    return 0;
}


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int M;

    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");


      M = Integer.parseInt(in_str_split[0]);

      UtilLog.ans_ln("" + (48 - M));
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 20948
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {  
	ll kazu=1;
	while(1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, K;cin >> N >> K;
	ll ans = 1;
	while (N / K > 0) {
		ans++;
		N/=K;
	}
	cout << ans << endl;
}

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

using namespace std;

const long long INF = 1e12;
const int N_MAX = 100000;
int N;
int a[N_MAX+10];
long long dp[N_MAX+10] = {};

int main() {
  int i, j;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < N; i++) {
    dp[i] = INF;
  }
  for (i = 0; i < N; i++) {
    *lower_bound(dp, dp+N, a[i]) = a[i];
  }
  int ans = lower_bound(dp, dp+N, INF) - dp;
  //for (i = 0; i < N+1; i++) {
  //  for (j = 0; j < W+1; j++) {
  //    printf("%d ", dp[i][j]);
  // }
  //  printf("\n");
  // }
  printf("%d\n", ans);
  return 0;
}



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

int dp[100000], peso[100000], N;

int solve(int i)
{
	if(dp[i] != -1) return dp[i];
	if(i == N) return dp[i] = 0;
 
	dp[i] = abs(peso[i] - peso[i + 1]) + solve(i + 1);
 
	if(i + 1 < N) dp[i] = min(dp[i], abs(peso[i] - peso[i + 2]) + solve(i + 2));
 
	return dp[i];
}
int main()
{
	
	
	memset(dp, -1, sizeof dp);
 
	cin >> N;
 
	for(int i = 1; i <= N; i++)
		cin >> peso[i];
 
	cout << solve(1) << endl;
 
	return 0;
}

Measured memory_bytes: 10616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {
	static int MAX = 10000;
	static int[] di = {0, 0, 1, -1};
	static int[] dj = {1, -1, 0, 0};
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] table = new char[H][];
		for (int i = 0; i < H; i++) {
			table[i] = sc.next().toCharArray();
		}
		int[][] dist = new int[H][W];
		for (int i = 0; i < dist.length; i++) {
			Arrays.fill(dist[i], -1);
		}
		int ans = 0;
		Deque<Integer> queue = new ArrayDeque<>();
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) if (table[i][j] == '#') {
				dist[i][j] = 0;
				queue.addLast(i * MAX + j);
			}
		}
		while (!queue.isEmpty()) {
			int cur = queue.removeFirst();
			int ii = cur / MAX;
			int jj = cur % MAX;
			for (int k = 0; k < 4; k++) {
				int ni = ii + di[k];
				int nj = jj + dj[k];
				if (0 <= ni && ni < H && 0 <= nj && nj < W && dist[ni][nj] == -1) {
					ans = dist[ni][nj] = 1 + dist[ii][jj];
					queue.addLast(ni * MAX + nj);
				}
			}
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

int inDegree[100010] = {0};
bool visited[100010];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while(t != 0) {
	    int n, m;
        cin >> n >> m;
        int u, v;
        map<int, vector<int> > adj;
        for(int i = 0; i < m; i++) {
            cin >> u >> v;
            adj[u].push_back(v);
            inDegree[v]++;
        }
        queue<pair<int, int> > q;
        memset(visited, false, sizeof visited);
        int ans = 1;
        for(int i = 1; i <= n; i++) {
            if(inDegree[i] == 0) {
                q.push({i, 1});
                visited[i] = true;
            }
        }
        while(!q.empty()) {
            auto p = q.front();
            q.pop();
            int parent = p.first;
            int val = p.second;
            ans = max(ans, val);

            for(auto child: adj[parent]) {
                if(!visited[child]) {
                    inDegree[child]--;
                    if(inDegree[child] == 0) {
                        visited[child] = true;
                        q.push({child, val+1});
                    }
                }
            }
        }
        cout << ans-1 << "\n";
	    t--;
	}
	return 0;
}


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
char a[223455];
int prv[223455], nxt[223455], cnt;

int main () {
	boost ();
	cin >> a + 1;
	int n = strlen (a + 1);
	for (int i = 1;i <= n;i ++) prv[i] = i - 1, nxt[i] = i + 1;
	for (int i = 1;i <= n;i ++) {
		if (a[i] != 'S' && a[i] != 'T') continue;
		if (a[prv[i]] == 'S' && a[i] == 'T') {
			a[prv[i]] = a[i] = '#';
			prv[i] = prv[prv[i]];
			prv[i + 1] = prv[i];
		}
	}
	for (int i = 1;i <= n;i ++) cnt += (a[i] == '#');
	cout << n - cnt;

	return 0;
}

        

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[51];
signed main() {
    int n; string s;
    while (cin >> s) {
        for (int h = 0; h < s.size(); h++) {
            if (s[h] == '@') {
                for (int i = 0; i < s[h + 1] - '0'; i++) {
                    cout << s[h + 2];
                }
                h += 2;
            }
            else {
                cout << s[h];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x1 ,y1,x2,y2;
    cin >> x1>>y1>>x2>>y2;
    int a=x2-x1,b=y2-y1;
    int u,i,o,p;
 u=x2-b;
 i=y2+a;
 o=x1-b;
 p=y1+a;
    cout << u<<' '<<i<<' '<<o<<' '<<p<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  ll W, H;
  ll x, y;
  int flag = 0;
  cin >> W >> H >> x >> y;
  if (x*2 == W && y*2 == H) flag = 1;
  //cout << std::defaultfloat;
  cout << setprecision(10);
  cout << W*H/double(2) << " " << flag << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<(a<c)<<endl;
  return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric
import Data.Char

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [n] <- getIntegers
  ; if n == 0 then return ()
    else do
      { print (sum (map digitToInt (show n)))
       ; loop
       }
  }
--

getIntegers :: IO [Integer]
getIntegers = map read . words <$> getLine
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn .  unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4572
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut ban: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let mut del_list: Vec<usize> = Vec::new();

    //行の確認
    for i in 0..h {
        let mut row_check = true;
        for j in 0..w {
            if ban[i][j] == '#' {
                row_check = false;
            }
        }
        if row_check {
            del_list.push(i);
        }
    }
    for _i in 0..del_list.len() {
        ban.remove(del_list.pop().unwrap());
    }

    //列の確認
    for i in 0..w {
        let mut column_check = true;
        for j in 0..ban.len() {
            if ban[j][i] == '#' {
                column_check = false;
            }
        }
        if column_check {
            del_list.push(i);
        }
    }

    
    for _i in 0..del_list.len() {
        let del_i = del_list.pop().unwrap();
        for j in 0..ban.len() {
            ban[j].remove(del_i);
        }
    }

    for i in ban.iter() {
        for j in i.iter() {
            print!("{}", j);
        }
        println!("");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int gcd(int p, int q) {
    while (q != 0) {
      int r = p % q;
      p = q; 
      q = r;
    }
    return p;
}
  
int main(){
    int k;
    scanf("%d", &k);
    long sum = 0;
    
    for (int a = 1; a <= k; a++)
      for (int b = 1; b <= k; b++)
        for (int c = 1; c <= k; c++)
          sum += gcd(gcd(a, b), c);
    
    printf("%ld", sum);
    return 0;
 }

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int n, a, b; cin >> n >> a >> b;
	cout << min(n*a, b) << endl;

	return 0;
}


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

#define DEBUG(x) cerr << #x << " = " << x << endl

const int INF = (int)1e9;

struct SegmentTree {
  int N;
  vector<vector<int>> data;
  SegmentTree(const vector<int> &X) {
    N = 1;
    while(N < (int)X.size()) N *= 2;
    data.resize(2*N - 1);
    for(int i = 0; i < (int)X.size(); ++i) {
      data[N - 1 + i].push_back(X[i]);
    }
    for(int i = (int)X.size(); i < N; ++i) {
      data[N - 1 + i].push_back(INF);
    }
    for(int i = N - 2; i >= 0; --i) {
      merge(data[2*i+1].begin(), data[2*i+1].end(), data[2*i+2].begin(), data[2*i+2].end(), back_inserter(data[i]));
    }
  }
  int query(int a, int b, int lower, int upper, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) {
      int ans = 0;
      ans += lower_bound(data[k].begin(), data[k].end(), lower) - data[k].begin();
      ans += data[k].end() - upper_bound(data[k].begin(), data[k].end(), upper);
      return ans;
    }
    return query(a, b, lower, upper, 2 * k + 1, l, (l + r) / 2) +
      query(a, b, lower, upper, 2 * k + 2, (l + r) / 2, r);
  }
};

int main() {
  int D; cin >> D;
  vector<int> X(D);
  for(int i = 0; i < D; ++i) {
    cin >> X[i];
  }
  SegmentTree S(X);
  int Q; cin >> Q;
  while(Q--) {
    int l, r, e;
    cin >> l >> r >> e;
    l--; r--;
    int a = min(X[l], X[r]) - e;
    int b = max(X[l], X[r]) + e;
    cout << S.query(l, r, a, b, 0, 0, S.N) << endl;
  }
}

Measured memory_bytes: 23276
n,m=map(int,input().split())
lmax=0
rmin=10**20
for i in range(m):
    l,r=map(int,input().split())
    lmax=max(lmax,l)
    rmin=min(rmin,r)
if lmax>rmin:
    print(0)
else:
    print(rmin-lmax+1)


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int N, M, x, y, v;
vector<int> g[1<<20];
vector<int> color(1<<20);
vector<int> dist(1<<20);
vector<int> visited(1<<20);
vector<int> V(1<<20), D(1<<20), C(1<<20);

void dfs(int s, int d, int c) {
	if(d < 0) return;
	if(visited[s] and d < dist[s]) return;

	if(visited[s]) {
		dist[s] = d;
		for(auto &y:g[s]) {
			if(not visited[y]) {
				dfs(y, d-1, c);
			} else if(d-1 > dist[y]) {
				dfs(y, d-1, c);
			}
		}
		return;
	}

	color[s] = c;
	dist[s] = d;
	visited[s] = true;
	for(auto &y:g[s]) {
		if(not visited[y]) {
			dfs(y, d-1, c);
		} else if(d-1 > dist[y]) {
			dfs(y, d-1, c);
		}
	}
}

int main() {
	//freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
	cin>>N>>M;
	rep(i, M) {
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}

	int q;
	cin>>q;
	rep(i, q) cin>>V[i]>>D[i]>>C[i];
	for(int i = q-1;i >= 0;i--) {
		dfs(V[i], D[i], C[i]);
	}

	rep(i, N) cout<<color[i+1]<<endl;

  return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	long long a, b, c;
	cin >> a >> b >> c;
	
	if(c <= a + b) {
		cout << b + c << endl;
		return 0;
	}
	else {
		cout << a + b + b  + 1<< endl;
	}
	return 0;	
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int a, b, c;
  int ans = 0;
  fscanf(stdin, "%d %d %d", &a, &b, &c);
  for (int i = a; i <= b; ++i) {
    if (c % i == 0) { ++ans; }
  }
  fprintf(stdout, "%d", ans);
  fprintf(stdout, "\n");
  return 0;
}

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

int main() {
  int N, M, A, cumsum = 0;
  cin >> N >> M;
  map<int, ll> S;
  S[0] = 1;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    cumsum = (cumsum + A) % M;
    ans += S[cumsum];
    S[cumsum]++;
  }
  cout << ans << endl;
}


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

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

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

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

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

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
  }
  ll ans = 0,sum = 0;
  rep(i,n){
    if(v[i]){
      sum += v[i];
    }
    else {
      ans += sum/2;
      sum = 0;
    }
  }
  ans += sum/2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1152
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
  public static void main(String[] args) throws Exception {
    String line = null;
    long num = 0;
    long rem = 0;
    long res = 0;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    line = br.readLine();
    String price[] = line.split(" ");
    line = br.readLine();
    long vol = Long.parseLong(line);
    // 配列に1リットルあたりの単価を登録
    long cost1 = Long.parseLong(price[0]) * 4;         // 0.25L
    long cost2 = Long.parseLong(price[1]) * 2;         // 0.50L
    long cost3 = Long.parseLong(price[2]);             // 1.00L
    long d_cost4 = Long.parseLong(price[3]);           // 2.00L * 2
    // 0.25L, 0.5L. 1Lの単価の最小値
    long minPrice = Math.min(Math.min(cost1, cost2), cost3);
    if (minPrice * 2 <= d_cost4) {
      res = minPrice * vol;
    } else {
      num = vol / 2;  // 2Lで買える数
      rem = vol % 2;  // 2Lで買えない数(1 or 0)
      res = (d_cost4 * num) + (minPrice * rem);
    }
    System.out.println(res);
  }

}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

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

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, d;
	cin >> n >> d;
	vi2 x(n, vector<int>(d));
	rep(i, n) rep(j, d) cin >> x[i][j];

	vi l;
	rep(i, n)
	{
		for(int j = i+1; j < n; j++)
		{
			int dis = 0;
			rep(k, d)
				dis += pow((x[i][k] - x[j][k]), 2);
			l.push_back(dis);
		}
	}
	int ans = 0;
	for(auto a : l)
	{
		rep(i, 4000)
			if(i * i == a) ans++;
	}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = a * b;
    int y = c * d;
    cout << max(x, y) << "\n";
    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

red = p[:X]
green = q[:Y]

all_apple = red+green+r
all_apple.sort(reverse=True)

print(sum(all_apple[:(X+Y)]))

Measured memory_bytes: 29484
<?php
fscanf(STDIN, "%d%d", $n, $m);
$ans_list = array_fill(1,$n,PHP_INT_MAX);
$count_list = $ans_list;
$map = array_fill(1,$n,[]);
$ans_list[1] = 0;
$count_list[1] = 0;
for($i = 0;$i<$m; $i++){

    fscanf(STDIN, "%d%d", $a, $b);
    $map[$a][$b] = 1;
    $map[$b][$a] = 1;

}
$queue = [];
getQueue($map[1], 1, 1);
$i=0;
while(isset($queue[$i])){
    if($count_list[$queue[$i][0]] > $queue[$i][2]){
        $ans_list[$queue[$i][0]] = $queue[$i][1];
        $count_list[$queue[$i][0]] = $queue[$i][2];
        getQueue($map[$queue[$i][0]], $queue[$i][0], $queue[$i][2]+1);
    }
    unset($queue[$i]);
    $i++;
}
$ans = "";
for($i=2;$i<=$n;$i++){
    if($ans_list[$i] === PHP_INT_MAX){
        echo "No";
        exit;
    }else{
        $ans .= $ans_list[$i].PHP_EOL;
    }
}

echo "Yes". PHP_EOL. $ans;
function getQueue($array, $last, $count){
    global $queue, $count_list;
    foreach($array as $key =>$value){
        if($count_list[$key] > $count){
            $queue[] = [$key, $last, $count];
        }
    }

    return 0;

}

Measured memory_bytes: 125036
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;


const int MAX_N = 100000;
int N;
int t[MAX_N+1], x[MAX_N+1], y[MAX_N+1];


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

  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> t[i] >> x[i] >> y[i];

  for (int i = 0; i < N; ++i) {
    int dst = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1]);
    int peri = t[i+1] - t[i];
    if (dst > peri || (peri-dst)%2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
n,k = map(int,input().split())
a = list(map(int,input().split()))
minus = []
plus = []
ans = 10**100
for x in a:
    if x <0:minus.append(-x)
    else:plus.append(x)
minus = minus[::-1]
for i in range(min(k+1,len(minus)+1)):#負のものをi個通る
    if k-i > len(plus):continue
    res = 0
    if i-1 >=0:res += minus[i-1]
    res*=2
    if k-i-1 >=0 and k-i <= len(plus):res += plus[k-i-1]
    ans = min(ans,res)
    res = 0
    if k-i-1 >=0 and  k-i <= len(plus):res += plus[k-i-1]
    res *=2
    if i-1 >=0:res += minus[i-1]
    ans = min(ans,res)
print(ans)

    
    
    
    


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

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

  int n;
  ll v = 0, e = 0;

  cin >> n;
  for (ll i = 1; i <= n; ++i) v += i * (n - i + 1);
  for (int i = 0; i < n-1; ++i) {
    ll l, r;
    cin >> l >> r;

    if (l > r) swap(l, r);
    e += l * (n - r + 1);
  }
  
  cout << v - e << endl;

  return (0);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

vector<ll> a,b;

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
		b.push_back(x);
	}
	ll m=n/2-1;
	sort(a.begin(),a.end());
	ll l=a[m],r=a[m+1];
	for(int i=0;i<n;i++){
		if(b[i]<=l){
			cout << r<<endl;
		}
		else{
			cout << l<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7268
N, M = map(int, input().split())
Alist = [list(input()) for _ in range(N)]
Blist = [list(input()) for _ in range(M)]
from sys import exit
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for A, B in zip(Alist[i:i + M], Blist):
            if A[j:j + M] != B:
                break
        else:
            print("Yes")
            exit()
print("No")


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Biscuit Generator
            var line = ReadLine();
            int a = line[0];
            int b = line[1];
            int t = line[2];
            int biscuits = 0;
            int i = 1;

            while (a * i <= t + 0.5)
            {
                biscuits += b;
                i++;
            }

            Console.WriteLine(biscuits);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n);
    long long total_sum = 0;
    for (int& a : as) {
        cin >> a;
        total_sum += a;
    }
    long long best = total_sum;
    sort(as.begin(), as.end());
    long long running_sum = 0;
    for (int i = 0; i+1 < n; i += 2) {
        running_sum += as[i] + as[i+1];
        best = max(best, total_sum - 2*running_sum);
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
using namespace std;

int INF = 1e9 + 7;

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

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

	cout << max(max(a + b, a - b), a*b) << endl;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        int[] a = Pattern.compile(" ").splitAsStream(stdin.nextLine()).mapToInt(Integer::parseInt).toArray();
        String ans = IntStream.range(0, n)
            .boxed()
            .sorted(Comparator.comparing(i -> a[i]))
            .map(i -> Integer.toString(i + 1))
            .collect(Collectors.joining(" "));
        System.out.println(ans);
    }
}


Measured memory_bytes: 62272
package main

import "fmt"

func main() {
	var N, x int
	fmt.Scan(&N, &x)

	a := make([]int, N)
	b := make([]int, N-1)
	for i := range a {
		fmt.Scan(&a[i])
		if i >= 1 {
			b[i-1] = a[i-1] + a[i]
		}
	}

	c := 0
	for i := range b {

		n := b[i] - x

		if n <= 0 {
			continue
		}

		c += n
		if i == len(b)-1 {
			break
		}

		var r int
		n -= a[i+1]
		if n > 0 {
			n -= a[i]
		} else if n < 0 {
			r = -n
		} else {
			r = 0
		}
		b[i+1] -= a[i+1] - r
		a[i+1] = r
	}
	fmt.Println(c)
}


Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef pair<int,int> pii;
// cin.tie(0);
// std::ios::sync_with_stdio(false);
// tree <pii,null_type,greater<pii>,rb_tree_tag,tree_order_statistics_node_update> tr;
typedef long long LL;
const int N = 3005;
const int M = 2000005;
const int INF = 0x3f3f3f3f;
const double Pi = acos(-1);
const int MOD = 1e9+7;
const double eps = 1e-8;
int n,m;
int a,b;
int s[N];
int dp[N][2];
int main()
{
    while(~scanf("%d%d%d",&n,&a,&b))
    {
        memset(dp,0,sizeof dp);
        for (int i=1;i<=n;i++)
            scanf("%d",&s[i]);
        for (int i=0;i<=n+1;i++)
        {
            dp[i][0] = -1;
            dp[i][1] = INF;
        }
        dp[n][1] = abs(s[n]-b);
        dp[n][0] = abs(s[n]-b);
        for (int i=n-1;i>0;i--)
        {
            dp[i][0] = abs(s[i]-s[n]);
            dp[i][1] = abs(s[i]-s[n]);
            for (int j=i;j<n;j++)
                dp[i][0] = min(dp[i][0],dp[j][1]);
            for (int j=i;j<=n;j++)
                dp[i][1] = max(dp[i][1],dp[j][0]);
        }
        // cout<<"bug"<<endl;
        // for (int i=1;i<=n;i++)
        //     cout<<dp[i][0]<<" ";
        // cout<<endl;
        // for (int i=1;i<=n;i++)
        //     cout<<dp[i][1]<<" ";
        // cout<<endl;
        int ans1 = -1;
        int ans2 = INF;
        for (int i=1;i<=n;i++)
        {
            ans1 = max(ans1,dp[i][0]);
            ans2 = min(ans2,dp[i][1]);
        }
        // cout<<ans1<<" "<<ans2<<endl;
        printf("%d\n",max(ans1,ans2));
    }
    return 0;
}

/*

3 100 100
10 1000 100

3 100 1000
10 100 100

5 1 1
1 1 1 1 1

1 1 1
1000000000

6 3 4
1 3 2 4 5 2

*/

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

int main(){
  int d;
  cin>>d;
  
  if(d==25)cout<<"Christmas"<<endl;
  if(d==24)cout<<"Christmas Eve"<<endl;
  if(d==23)cout<<"Christmas Eve Eve"<<endl;
  if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
}


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

using namespace std;

#define int long long

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef unordered_map<int,int> mii;
typedef unordered_map<char,int> mci;
typedef unordered_map<string,int> msi;

#define pb push_back
#define f first
#define s second 
 

void solve() {
    int n,W;
    cin>>n>>W;
    vi w(n),v(n);
    for(int i=0;i<n;i++) {
        cin>>w[i]>>v[i];
    }
    vvi dp(n+1,vi(W+1));
    for(int i=0;i<=n;i++) {
        dp[i][0] = 0;
    }
    for(int i=0;i<=W;i++) {
        dp[0][i] = 0;
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=W;j++) {
            dp[i][j] = dp[i-1][j];
            if(j>=w[i-1]) {
                dp[i][j] = max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
        }
    }
    cout<<dp[n][W]<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //#ifdef ONLINEJUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int tc; tc=1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 83104
#include <iostream>

using namespace std;

int main()
{
   /* int k,n,d=1,b,c=0,f;
    cin>>n>>k;
    if(k==2 && n==1)
    {
        b=2;
        cout<<b;
    }
    else if( n>=k)
    {
        while(d<=k)
        {
            d*=2;
            c++;
        }

        b=((n-c)*k)+d;
        cout<<b;
    }
    else if(k>2 && n<k){
        b=1<<n;
        cout<<b;
   }*/
   int n,k,b=1,c=0;
   cin>>n>>k;
   while(b<=k && c<n){
    b*=2;
    c++;
   }
   for(int i=c+1;i<=n;i++)
    b+=k;
    cout<<b;

    return 0;
}


Measured memory_bytes: 768