akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
using namespace std;
int n,dp[100009][3],a[100009],b[100009], c[100009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for (int i = 0; i < n - 1; i++) {
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1];
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1];
		dp[i + 1][2] = max(dp[i][1], dp[i][0]) + c[i + 1];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	//system("pause");
}

Measured memory_bytes: 2560
N = int(input())
A = list(map(int,input().split()))
A_copy = A.copy()
n = N//2
A.sort()
avg = (A[n]+A[n-1])/2
for i in A_copy:
    if i < avg:
        print(A[n])
    else:
        print(A[n-1])

Measured memory_bytes: 26772
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int ans = 1;

		for (int i = 0; i < n; i++) {
			if (i == 0) {
				ans *= k;
			} else {
				ans *= (k - 1);
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    double ans = 0;
    if (d == 0) {
        ans = 1.0 / n;
    } else {
        ans = 2.0 * (n - d) / pow(n, 2.0);
    }
    cout << fixed << setprecision(10) << ans * (m - 1) << endl;
}


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

using namespace std;
long long dp[100009][3],n,arr[100009][3];
int bt(int x,int b)
{
    if(dp[x][b]!=-1)
        return dp[x][b];
    if(x==n)
        return 0;
    long long &ret=dp[x][b]=-1;
    for(int i=0;i<3;i++)
    {
        if(i==b)
            continue;
        ret=max(bt(x+1,i)+arr[x+1][i],ret);
    }
    return ret;
}
int main()
{
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    cout<<max(bt(0,0)+arr[0][0],max(bt(0,1)+arr[0][1],bt(0,2)+arr[0][2]));
}


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

int main()
{
	int n, a, b, c;
	int d[100];

	cin >> n >> a >> b >> c;

	for (int i = 0; i < n; i++)
		cin >> d[i];

	sort(d, d + n, greater<int>());

	int m = 0, nr = c, dr = a, m1 = nr / dr;

	for (int i = 0; i < n; i++) {
		m = max(m, m1);
		nr += d[i];
		dr += b;
		m1 = nr / dr;
	}

	cout << m << endl;

	return 0;
}



Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		if(A >= 13) {
			System.out.println(B);
		}else if(A >= 6 && A <= 12) {
			System.out.println(B/2);
		}else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int A, B, C, answer;
int main(){
 cin >> A >> B >> C;
 if(A <= C){
	answer += A;
	C -= A;
	if(B >= C){
	 answer += B + C;
	}else{
	 answer += B + B + 1;
	}
 }else{
	answer += C + B;
 } 
 cout << answer << endl;
 return 0;
};


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

using namespace std;
#define ll long long int


int main()
{
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=0;i<n-1;i++){
        int w;
        cin >> w;
        mp[w]++;
    }
    for(int i=1;i<=n;i++){
        cout << mp[i] << endl;
    }
}


Measured memory_bytes: 12964
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int h = sc.nextInt();
    int w = sc.nextInt();

    int a = sc.nextInt();
    int b = sc.nextInt();

    int[] r = new int[h];
    int[] c = new int[w];

    int[][] matrix = new int[h][w];

    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if ((r[y] < w - a) && (c[x] < h - b)) {
          matrix[y][x] = 1;
          r[y]++;
          c[x]++;
        }
      }
    }

    for (int i = 0; i < h; i++) {
      if (r[i] != a && r[i] != w - a) {
        os.println("No");
        return;
      }
    }
    for (int i = 0; i < w; i++) {
      if (c[i] != b && c[i] != h - b) {
        os.println("No");
        return;
      }
    }
    for (int y = 0; y < h; y++) {
      StringBuilder s = new StringBuilder();
      for (int x = 0; x < w; x++) {
        s.append(matrix[y][x]);
      }
      os.println(s);
    }
  }
}

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

using namespace std;

int main(){
	int a,b;
	while(cin>>a>>b){
		if(a==0&&b==0)break;

		int  n;
		int dp[25][25]={0};
		dp[1][1]=1;//?§????

		cin>>n;
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			dp[y][x]=-1;
		}

		for(int y=1;y<=b;y++){
			for(int x=1;x<=a;x++){
				if(dp[y][x]!=-1){
					if(y!=1&&dp[y-1][x]!=-1){
						dp[y][x]+=dp[y-1][x];
					}if(x!=0&&dp[y][x-1]!=-1){
						dp[y][x]+=dp[y][x-1];
					}
				}
			}
		}

		cout<<dp[b][a]<<endl;

	}
}

Measured memory_bytes: 3028
#include <stdio.h>
#include <stdlib.h>

#define T_MAX 50
#define P_MAX 10
#define PENALTY_UNIT 1200

typedef struct team { int tid, wa_count[P_MAX + 1], ac_count, penalty; } team_t;
team_t teams[T_MAX + 1];

int cmp_teams(const void *a, const void *b)
{
    team_t at = *(team_t*)a, bt = *(team_t*)b;

    if(at.ac_count != bt.ac_count)
        return at.ac_count > bt.ac_count ? -1 : 1;
    else if(at.penalty != bt.penalty)
        return at.penalty < bt.penalty ? -1 : 1;
    else if(at.tid != bt.tid)
        return at.tid < bt.tid ? -1 : 1;
    else
        return 0;
}

int main(void)
{
    int t, p, r, tid, pid, time, i, j;
    char message[8];

    while(scanf("%d %d %d", &t, &p, &r), t + p + r)
    {
        /* initialize */
        for(i = 1; i <= t; i++)
        {
            teams[i].tid = i;
            for(j = 1; j <= p; j++)
                teams[i].wa_count[j] = 0;
            teams[i].ac_count = 0;
            teams[i].penalty = 0;
        }

        /* read inputs */
        while(r--)
        {
            scanf("%d %d %d %s", &tid, &pid, &time, message);

            switch(*message)
            {
              case 'W':
                teams[tid].wa_count[pid]++;
                break;

              case 'C':
                teams[tid].ac_count++;
                teams[tid].penalty += teams[tid].wa_count[pid] * PENALTY_UNIT + time;
                break;
            }
        }

        /* sort */
        qsort(teams + 1, t, sizeof(team_t), cmp_teams);

        /* print */
        for(i = 1; i <= t; i++)
            printf("%d %d %d\n", teams[i].tid, teams[i].ac_count, teams[i].penalty);
    }

    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define p(x) {cout<<x <<endl;}

 
void solve()
{
	int n, x, ans=0;
	cin>>n;
	if(n>=400 and n<600){
		ans=8;
	}
	else if(n>=600 and n<800){
		ans=7;
	} 
	else if(n>=800 and n<1000){
		ans=6;
	} 
	else if(n>=1000 and n<1200){
		ans=5;
	} 
	else if(n>=1200 and n<1400){
		ans=4;
	} 
	else if(n>=1400 and n<1600){
		ans=3;
	} 
	else if(n>=1600 and n<1800){
		ans=2;
	}
	else{
		ans=1;
	} 
	
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3608
//import for Scanner and other utility classes
import java.util.*;
import java.io.*;
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    public static void main(String args[] ) {
        Scanner s = new Scanner(System.in);
       int n=s.nextInt();
      int k=s.nextInt();
int a[]=new int[n];
int c=0;
for(int i=0;i<n;i++){
a[i]=s.nextInt();
if(a[i]>=k)
c++;
}
      System.out.print(c);
      
        // Write your code here
 
    }
}

Measured memory_bytes: 48760
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e5 + 9, M = 1e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

string str;
ll mem[N][14];

ll add(ll x, ll y) {
  x += y;
  while(x >= MOD)
    x -= MOD;
  while(x < 0)
    x += MOD;
  return x;
}

ll solve(int idx, int mod) {
  if(idx == (int)str.size())
    return (mod == 5);
  ll& ret = mem[idx][mod];
  if(~ret)
    return ret;
  ret = 0;
  if(str[idx] != '?') {
    ret = solve(idx + 1, (mod * 10 + (str[idx] - '0')) % 13);
  } else {
    for (int i = 0; i < 10; ++i)
      ret = add(ret, solve(idx + 1, (mod * 10 + i) % 13));
  }
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> str;
  memset(mem, -1, sizeof mem);
  cout << solve(0, 0);
  return 0;
}


Measured memory_bytes: 37968
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i;
  string s,t;
  cin >> s;
  n=s.size();
  for(i=0;i<n;i++){
    t=s.substr(i,1);
    if(i%2==0&&t=="L" || i%2==1&&t=="R"){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    int d,n,ans;

    scanf("%d %d",&d ,&n );



    if(n <= 99){
        ans = pow(100,d) * n;
    }else{
        ans = (pow(100,d) * n) + pow(100,d);
    }

    printf("%d",ans); 

}

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

int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D) {
    cout << "Left" << endl;
  }
  
  if(A + B < C + D) {
    cout << "Right" <<endl;
  }
  
  if(A + B == C + D) {
    cout << "Balanced" << endl;
  }
}
    

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

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

Measured memory_bytes: 3580
#include<iostream>
#include<string>

using namespace std;

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

	int cnt = 2;
	int mojisu = 1;
	int Slen = static_cast<int>(str.length());

	string tmp = str.substr(0, mojisu);

	for (int i = 1; i < Slen; i++) {
		for (int j = 1; j < Slen - i; j++) {
			if (tmp != str.substr(i, j)&& str.substr(i,j)!=str.substr(i+j)) {
				cnt++;
				tmp = str.substr(i, j);
				i += j - 1;
				break;
			}
		}
		
	}
		
	cout << cnt;

	return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a) {
    return modpow(a, MOD - 2);
}

int main(){
	ll n, k, mincoun = 0;
	cin >> n >> k;
	if (k == n){
		ll ans = 1;
		for (int i = 0; i < n; i++){
			ll x;
			cin >> x;
			ans = ans * x % MOD;
		}
		if (ans < 0) cout << ans + MOD << endl;
		else cout << ans << endl;
		return 0;
	}
	vector<ll> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (a[i] < 0) mincoun++;
	}
	if (mincoun == n && k % 2){
		sort(a.begin(), a.end(), greater<ll>());
		ll ans = 1;
		for (int i = 0; i < k; i++){
			ans = ans * a[i] % MOD;
		}
		cout << MOD + ans << endl;
		return 0;
	}
	vector<pair<ll, ll> > vec(n);
	for (int i = 0; i < n; i++){
		vec[i] = make_pair(abs(a[i]), a[i]/abs(a[i]));
	}
	sort(vec.begin(), vec.end(), greater<pair<ll, ll> >());

	ll ans = 1, coun = 0;
	for (int i = 0; i < k; i++){
		if (vec[i].second == -1) coun++;
		ans = ans * vec[i].first % MOD;
	}
	if (ans == 0){
		cout << ans << endl;
		return 0;
	}
	if (coun % 2){
		ll prid = MOD, mrid = MOD;
		ll pin = -1, miin = -1;
		for (int i = 0; i < k; i++){
			if (vec[i].second == 1){
				prid = llmin(prid, vec[i].first);
			}else if(vec[i].second == -1){
				mrid = llmin(mrid, vec[i].first);
			}
		}
		for (int i = k; i < n; i++){
			if (vec[i].second == -1){
				miin = llmax(miin, vec[i].first);
			}else{
				pin = llmax(pin, vec[i].first);
			}
		}
		if ((prid != MOD && miin != -1) && (mrid != MOD && pin != -1)){
			if (miin*mrid > pin*prid){
				cout << (ans * modinv(prid))%MOD*miin%MOD << endl;
			}else{
				cout << (ans * modinv(mrid))%MOD*pin%MOD << endl;
			}
		}else if (prid != MOD && miin != -1){
				cout << (ans * modinv(prid))%MOD*miin%MOD << endl;
		}else{
				cout << (ans * modinv(mrid))%MOD*pin%MOD << endl;
		}
	}else{
		cout << ans << endl;
	}
	return 0;
}


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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll mult(ll a,ll b,ll mod) {
	return ll(a)*b%mod;
}


//b^e mod mod. O(log e)
ll pmod(ll b,ll e,ll mod) {
	if (e==0) return 1%mod;
	ll r=pmod(b,e/2,mod);
	r=mult(r,r,mod);//(ll)r*r%mod;
	if (e%2) r=mult(r,b,mod);//(ll)r*b%mod;
	return r;
}

//Extended Euclidean Algorithm. O(log(min(m,n)))
//All operations don't overflow
//abs(g) is gcd (Note that it could be negative)
//am+bn=g with abs(a)<abs(n)/g and and abs(b)<abs(m)/g except when m or n is 0
//in which case a and b are 0 and 1 (in some order).
//
//The proof follows easily from
// |b| <= |a'|+|m/n||b'| <= |r|+|m/n||n| (inductive step when m,n coprime)
// == |r+m/n*n| (sign r == sign m for truncated division)
// == |m|

int aa,b,g;
void gcd(int m,int n) {
    if (n==0) {aa=1;b=0;g=m;return;}
    gcd(n,m%n);
    int t=aa-b*(m/n);
    aa=b;b=t;
}

//Multiplicative inverse of a mod mod. O(log(min(a,mod)))
//The remarks above show that |inv(a,mod)|<|mod|/|gcd(a,mod)| but inv(a,mod)
//can be positive or negative even when both a and mod are positive.
//If a and mod aren't coprime then the inverse doesn't exist and in general we
//have a*inv(a,mod) = abs(gcd(a,mod)) (mod mod)

int inv(int a,int mod) {
	gcd(mod,a);
	return g>0?b:-b;
}


int n,cts[1000001],a[100001],dub,m;

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

	cin >> n;
	for (int i=0;i<=n;i++) {
		cin >> a[i];a[i]--;
		cts[a[i]]++;
		if (cts[a[i]]==2) dub=a[i];
	}

	for (int i=0;a[i]!=dub;i++,m++);
	for (int i=n;a[i]!=dub;i--,m++);

	ll f1=1,f2=1;
	for (int i=1;i<=n+1;i++) {
		//if (i!=1) cout << ' ';
		f1=f1*(n+2-i)%mod*inv(i,mod)%mod;
		ll r=(f1-f2)%mod;
		if (r<0) r+=mod;
		cout << r << '\n';
		f2=f2*(m+1-i)%mod*inv(i,mod)%mod;
	}
	//cout << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  ll x;
  cin >> x;
  ll k = 100;
  ll cnt = 0;
  while(k < x){
    long double l = k;
    l *= 1.01;
    k = l;
    cnt++;
  }
  cout << cnt << endl;
  



  

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	long long int N; 
	cin >> N; 
	//12…m12…mで(2^m)-1通りできる．
	//12…m(m+1)12…i(m+1)(i+1)…mとすると2^i通り増える．
	//これを繰り返してNにする．高々160文字くらいなので制約もOK．
	vector<int> ans; 
	long long int P[50] = {};
	P[0] = 0;
	for(int i = 1; i <= 45; i++){
		P[i] = 2 * P[i-1] + 1;
	}
	int R = (upper_bound(P, P+45, N) - P) - 1; 
	for(int i = 1; i <= R; i++){
		ans.push_back(i); 
	}
	long long int S = N - P[R]; 
	int count = R; 
	for(int j = 45; j >= 0; j--){
		long long int T = (S >> j); 
		if(T & 1){
			count ++; 
			ans.insert(ans.begin() + j, count); 
		}
	}
	int A = ans.size(); 
	cout << A * 2 << endl; 
	for(int i = 1; i <= A; i++){
		cout << i << " "; 
	}
	for(int i = 0; i < A; i++){
		cout << ans.at(i) << " "; 
	}
	cout << endl; 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    vector<map<ll,ll>> dp(N+2);
    
    dp[1][0] = 0;
    dp[2][1] = A[0];
    for(int i = 1; i < N;i++){
        for(int j = max(0,(i-1)/2); j <= (i+1)/2; j++){
            if(dp[i].count(j)){
                if(dp[i+1].count(j) == 0) dp[i+1][j] = -LINF;
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
                
                if(dp[i+2].count(j+1) == 0) dp[i+2][j+1] = -LINF;
                dp[i+2][j+1] = max(dp[i+2][j+1],dp[i][j]+A[i]);
            }
        }
    }
    res = max(dp[N][N/2],dp[N+1][N/2]);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 39072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c)cout << "Yes" << endl;
	else if (a == c && a != b)cout << "Yes" << endl;
	else if (b == c && a != b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
         cout << std::fixed << std::setprecision(15);
string a,v;
cin>>a;
int nx[a.size()],p['z'-'a'+1];char ans[a.size()];
fill(p,p+26,a.size());int t=26;bool x[26];fill(x,x+26,false);
for(int i=a.size()-1;i>=0;i--){
for(int j=0;j<26;j++)if(x[j]==false){
     nx[i]=p[j];
     ans[i]=char(j+'a');
     break;
}
if(x[a[i]-'a']==false){
     x[a[i]-'a']=true;
     t--;
}
p[a[i]-'a']=i;
if(t==0){
     t=26;
     fill(x,x+26,false);
}
}
for(int j=0;j<26;j++)if(x[j]==false){
     t=p[j];
     v.push_back(char(j+'a'));
     break;
}
while(t!=a.size()){
     v.push_back(ans[t]);
     t=nx[t];
}
cout<<v<<endl;

     }

 


 






    





      

        


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

bool flg = false;

int main() {
  int C[3][3],C1[3][3],C2[3][3],C3[3][3],C4[3][3],C5[2][3];
  for (int i = 0; i<2; i++) for (int j = 0; j<3; j++) C5[i][j] = 0;
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) cin >> C[i][j];
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) C1[i][j] = C[i][(j+1)%3]-C[i][j];
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) C2[i][j] = C[(i+1)%3][j]-C[i][j];
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) C3[i][j] = C1[(i+1)%3][j]-C1[i][j];
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) C4[i][j] = C2[i][(j+1)%3]-C2[i][j];
//  for (int i = 0; i<3; i++) C5[0][i] = C1[i][0]+C1[i][1]+C1[i][2];
//  for (int i = 0; i<3; i++) C5[1][i] = C2[0][i]+C2[1][i]+C2[2][i];

  
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) if(C3[i][j] != 0 && flg ==false) {
    cout << "No\n";
    flg = true;
  }
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) if(C4[i][j] != 0 && flg ==false) {
    cout << "No\n";
    flg = true;
  }
//  for (int i = 0; i<2; i++) for (int j = 0; j<3; j++) if(C5[i][j] != 0 && flg ==false) {
//    cout << "No\n";
//    flg = true;
//  }

  if(flg == false) cout << "Yes\n";
}

Measured memory_bytes: 256
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    PX = [
        tuple(map(int, input().split()))
        for i in range(M)
    ]

    for p, x in PX:
        s = 0
        for i, t in enumerate(T, 1):
            if p == i:
                t = x
            s += t
        print(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import std.stdio, std.string,
			 std.conv, std.array, std.algorithm;

void main(){
	foreach(str; stdin.byLine()){
		if(str == "") break;
		auto tmp = str.split(" ").map!(to!int);
		auto res = tmp[0] + tmp[1];
		res = cast(int)res.to!string.length;
		writeln(res);
	}
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  ll a;
  cin >> a;
  long double b;
  cin >> b;
  ll ans = a*b;
  cout << ans << endl;
}


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


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

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    int n;
    int l[2001];
    int ans=0;
    int tmp;
    int loop=0;
    
    scanf("%d", &n);
    
    for(int i=1; i<=n; i++){
        
        scanf("%d", &l[i]);
        
    }
    
    for(int i=1; i<=n; i++){
        
        for(int j=i+1; j<=n; j++){
            
            if(l[i]>l[j]){
                
                tmp = l[i];
                l[i] = l[j];
                l[j] = tmp;
                
            }
            
        }
        
    }
    
    for(int p=1; p<=n-2; p++){
        
        for(int q=p+1; q<=n-1; q++){
            
            loop = 0;
            
            for(int r=q+1; loop<999999; r++){
                
                loop += 1;
                
                if(l[p]+l[q]<=l[r]){ // kokokara-muri
                    
                    ans += r - q - 1;
                    
                    break;
                    
                } else if(loop>=n-q){ // owari
                    
                    ans += r - q;
                    
                    break;
                    
                } else if(l[p]+l[q]>l[n-r+q+1]){ // kokomade-dekiru
                    
                    ans += n - r + 1;
                    
                    break;
                    
                }
                
                loop += 1;
                
            }
            
        }
        
    }
    
    printf("%d", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
/**********************************************************
* @Author: 			   Kirito
* @Date:   			   2020-07-25 20:10:42
* @Last Modified by:   Kirito
* @Last Modified time: 2020-07-25 20:18:46
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=211111;
int a[maxn],n,k;

int main()
{
	FAST;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i+k<=n;i++){
		if(a[i+k]>a[i])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n; cin >> n;
	
	int a[n], b[n], c[n];
	
	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
	
	int dp[n + 1][3];
	
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			switch (j)
			{
				case 0:
					dp[i][j] = a[i - 1] + max(dp[i - 1][1], dp[i - 1][2]);
					break;
				
				case 1:
					dp[i][j] = b[i - 1] + max(dp[i - 1][0], dp[i - 1][2]);
					break;
				
				case 2:
					dp[i][j] = c[i - 1] + max(dp[i - 1][0], dp[i - 1][1]);
					break;
			}
		}
	}
	
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
	
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> n >> h >> w;
    int a, b;
    /*
    if(n % h){
        a = n / h + 1;
    }else{
        a = n / h;
    }
    
    if(n % w){
        b = n / w + 1;
    }else{
        b = n / w;
    }
    */
    a = n - h + 1;
    b = n - w + 1;
    int ans = a * b;
    cout << ans << endl;
}

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

int main(){
    int M,K,N;

    cin >> M >> K;
    N = pow(2,M) - 1;

    if(K == 0){
        for(int i = 0;i <= N;i++){
            cout << i << ' ' << i << (i<N?' ':'\n');
        }
        return 0;
    }

    if(K > N || (K == 1 && M == 1)){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 0;i <= N;i++){
        if(i == K)continue;
        cout << i << ' ';
    }
    cout << K << ' ';

    for(int i = N;i >= 0;i--){
        if(i == K)continue;
        cout << i << ' ';
    }
    cout << K << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz 32
using namespace std;
int main(){
	int arr[sz] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<arr[k-1]<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e2;

int a[5],v[5][MaxN + 5];

int main()
{
	long long sum,ans1,ans2,ans3,ans4,ans;
	int n,m,w1,p,q,p1,q1,biu;
	while(~scanf("%d %d",&n,&m))
	{
		ans = 0;
		sum = 0;
		ans1 = 0;
		ans2 = 0;
		ans3 = 0;
		ans4 = 0;
		memset(v,0,sizeof(v));
		memset(a,0,sizeof(a));
		scanf("%d %d",&w1,&v[1][++a[1]]);
		for(int i = 2;i <= n;i++)
		{
			scanf("%d",&p);
			p = p-w1+1;
			scanf("%d",&v[p][++a[p]]);
		}
		for(int i = 1;i <= 4;i++) sort(v[i]+1,v[i]+1+a[i],greater<int>());
		p = m/w1;
		for(int i = 0;i <= p;i++)
		{
			for(int y = 0;y <= i;y++) ans1 += v[1][y];
			q = (m-i*w1)/(w1+1);
			for(int j = 0;j <= q;j++)
			{
				for(int y = 0;y <= j;y++) ans2 += v[2][y];
				p1 = (m-i*w1-j*(w1+1))/(w1+2);
				for(int k = 0;k <= p1;k++)
				{
					for(int y = 0;y <= k;y++) ans3 += v[3][y];
					q1 = (m-i*w1-j*(w1+1)-k*(w1+2))/(w1+3);
					for(int l = 0;l <= q1;l++)
					{
						for(int y = 0;y <= l;y++) ans4 += v[4][y];
						ans = ans1+ans2+ans3+ans4;
						sum = max(ans,sum);
						ans4 = 0;
					}
					ans3 = 0;
				}
				ans2 = 0;
			}
			ans1 = 0;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#define R_MAX 101
#define C_MAX 101

int array[R_MAX][C_MAX];

int main()
{
	int r, c;
	scanf("%d %d", &r, &c);

	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			scanf("%d", &array[i][j]);
		}
	}

    // 行合計
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			array[i][c]+=array[i][j];
		}
	}

    // 列合計
    for (int i =0;i<=c;i++)
    {
        for (int j=0;j<r;j++)
        {
            array[r][i]+=array[j][i];
        }
    }
    
	for (int i = 0; i <= r; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			std::cout<<array[i][j];
			if(j!=c)std::cout<<" ";
		}
		std::cout<<std::endl;
	}
}


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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
 #define LOOP 10000000

int main() {
  
  int A,B;
  int num[3] = {0,};

  cin >> A >> B;

  num[A-1]++;
  num[B-1]++;

  REP(i, 3){
      if(!num[i]) cout << ++i << endl;
  }

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int n; cin>>n;
    if (n & 1) {
        cout << setprecision(12) << ((n>>1)+1)/(double)n << endl;
    } else {
        cout << "0.5000000" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	class point{

		double x;

		double y;

		point(double x, double y){

			this.x = x;

			this.y = y;

		}

		point rot(point arg){

			point sc = arg.norm();

			double sin = sc.y;

			double cos = sc.x;

			point ret = new point(0,0);

			ret.x = x*cos - y*sin;

			ret.y = x*sin + y*cos;

			return ret;

		}

		point rot_inv(point arg){

			point s = new point(arg.x,-arg.y);

			return rot(s);

		}

		

		double abs(){

			return Math.sqrt(x*x+y*y);

		}

		point norm(){

			return new point(x/abs(),y/abs());

		}

		point org(point orgin){

			return new point(this.x-orgin.x,this.y-orgin.y);

		}

		point  add(point p){

			return new point(x+p.x,y+p.y);

		}

	}

	

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;sc.hasNextLine();){

			String buffer =sc.nextLine();

			Scanner in = new Scanner(buffer.replace(',', ' '));

			point a = new point(in.nextDouble(),in.nextDouble());

			point b = new point(in.nextDouble(),in.nextDouble());

			point p = new point(in.nextDouble(),in.nextDouble());

			point orged_b = b.org(a);

//			System.out.println(orged_b.x+" "+orged_b.y);

			point orged_p = p.org(a);

//			System.out.println(orged_p.x+" "+orged_p.y);

			point roted_p = orged_p.rot_inv(orged_b);

//			System.out.println(roted_p.x+" "+roted_p.y);

			point roted_syn_p = new point(roted_p.x, -roted_p.y);

//			System.out.println(roted_syn_p.x+" "+roted_syn_p.y);

			point orged_syn_p = roted_syn_p.rot(orged_b);

//			System.out.println(orged_syn_p.x+" "+orged_syn_p.y);

			point syn_p = orged_syn_p.add(a);

			System.out.println(syn_p.x+" "+syn_p.y);

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

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

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  for(int i=0;i<N;i++)v[i]--;
  int ok=0;
  for(int i=1;i<N;i++)if(v[i]-v[i-1]<0)ok++;
  if(ok==0){cout<<0<<endl;return 0;}
  int l=0;int r=N;
  std::vector<int> w(N);
  for(int i=0;i<N;i++)w[v[i]]=i;
  int k=0;
  int c=0;
  for(int i=1;i<N;i++){
    if(w[i]<w[i-1]){
      k=max(k,c);
      c=0;
    }
    else c++;
  }
  cout<<N-k-1<<endl;
}


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

class Program{

  static int n;
  static int ans = 0;

  static int Main() {

    string nyu = Console.ReadLine();
    n = int.Parse(nyu);

    int[] a = new int[n];
    string[] nya = Console.ReadLine().Split(' ');
    for (int i = 0; i < n; i++) {
      a[i] = int.Parse(nya[i]);
      while (true) {
        if (a[i] % 2 == 0) {
          a[i] = a[i] / 2;
          ans++;
        } else {
          break;
        }
      }
    }

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


Measured memory_bytes: 13792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    string S,T,U;
    cin >> S >> T;
    char r;
    REP(i,S.size()){
        U=T;
        r=T[T.size()-1];
        REP(j,S.size()-1){
            T[j+1]=U[j];
        }
        T[0]=r;
        //cout << T << endl;
        if(S==T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S[1] == 'B')
        S[1] = 'R';
    else
        S[1] = 'B';
    cout << S << endl;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int c[10][10];

int main() {
    int N; cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 10 == 0) continue;
        int l = i, r;
        while (l > 9) l /= 10;
        r = i % 10;
        c[l-1][r-1]++;
    }
    int ans = 0; 
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, u, w, deg[100001] = {};
	list *adj[100001] = {}, e[100001], *p;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i].v = w;
		e[i].next = adj[u];
		adj[u] = &(e[i]);
		deg[w]++;
	}
	
	int dist[100001] = {}, q[100001], head, tail;
	for (i = 1, tail = 0; i <= N; i++) if (deg[i] == 0) q[tail++] = i;
	for (head = 0; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (dist[u] + 1 > dist[w]) dist[w] = dist[u] + 1;
			deg[w]--;
			if (deg[w] == 0) q[tail++] = w;
		}			
	}
	
	int max = 0;
	for (i = 1; i <= N; i++) if (dist[i] > max) max = dist[i];
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

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

int main(void) {
    int N, X, Y;
    cin >> N >> X >> Y;
    --X;
    --Y;
    vector< int > d(N + 10);
    for (int i = 0; i < N + 10; i++) {
        d[i] = 0;
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (j <= X || Y <= i) {
                ++d[j - i];

            } else if (i <= X && Y <= j) {
                ++d[j - i - (Y - X - 1)];
            } else if (X <= i && j <= Y) {
                int t = min(j - i, (i - X) + (Y - j) + 1);
                ++d[t];
            } else if (i <= X) {
                int t = X - i + min(j - X, Y - j + 1);
                ++d[t];
            } else {
                int t = j - Y + min(Y - i, i - X + 1);
                ++d[t];
            }
        }
    }
    for (int i = 1; i < N; i++) {
        printf("%d\n", d[i]);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Double x1=sc.nextDouble();
        Double y1=sc.nextDouble();
        Double x2=sc.nextDouble();
        Double y2=sc.nextDouble();
        sc.close();
        System.out.println(Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
    }
}




Measured memory_bytes: 27920
#include <cstdio>
using namespace std;
int main(void){
    char b;
    scanf(" %c", &b);
    if(b == 'A') printf("%c\n", 'T');
    if(b == 'T') printf("%c\n", 'A');
    if(b == 'G') printf("%c\n", 'C');
    if(b == 'C') printf("%c\n", 'G');
}

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

#define ll long long
int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  //各 i (1<=i<=N) について, N以下のiの倍数を足したものを加えていく
  for (int i = 1; i <= N; i++) {
    ll X = N / i;
    ans += X * (X+1) * i / 2;
  }
  //
  
  cout << ans << endl;

}

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

int main()
{
  int N,K;scanf("%d %d",&N,&K);
  int h[N];
  for(int i=0;i<N;i++)scanf("%d\n",&h[i]);
  sort(h,h+N);int ans=1000000000;
  for(int i=0;i<N-K+1;i++)ans=min(ans,h[i+K-1]-h[i]);
  cout<<ans;
}

Measured memory_bytes: 4080
n,m = map(int,input().split())
d = []
for i in range(m):
    d.append(list(map(int,input().split())))
p = list(map(int,input().split()))

ans = 0
def search(x):
    global ans
    cnt = 0
    for i in range(m):
        c = 0
        for j in d[i][1:]:
            if x[j-1]==1:
                c += 1
        if c%2==p[i]:
            cnt += 1
    if cnt==m:ans+=1

from itertools import product
o = product(range(2),repeat=n)
for i in o:
    search(i)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
    int c0 = 0, c1 = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='0') c0++;
        if(s[i]=='1') c1++;
    }
    cout << min(c0, c1) * 2 << endl;
}

Measured memory_bytes: 512
<?php
list($n) = ints();
$k = 26;
$c = ints();
$last = array_fill(0, $k, 0);
for ($i = 1; $i <= $n; ++$i) {
    $s = ints();
    $max = PHP_INT_MIN;
    for ($p = 0; $p < $k; ++$p) {
        $ts = ($score[$i - 1] ?? 0) + $s[$p];
        for ($q = 0; $q < $k; ++$q) {
            if ($p === $q) continue;
            $ts -= $c[$q] * ($i - $last[$q]);
        }
        if ($ts > $max) {
            $max = $ts;
            $maxp = $p;
        }
    }
    $score[$i] = $max;
    $ans[$i] = $maxp + 1;
    $last[$maxp] = $i;
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    vector<double> q(n);
    rep(i, n) q[i] = (p[i] + 1.0) / 2.0;
    double ans = 0;
    rep(i,k) ans += q[i];
    double tmp = ans;
    rep(i, n - k)
    {
        tmp = tmp - q[i] + q[i+k];
        ans = max(ans, tmp);
    }
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで

int main() {
  int n, k;
  cin >> n >> k;
  int d[k], b[10]={0};
  for(int i=0; i<k; i++){
    cin >> d[i];
    b[d[i]]=1;
  }
  for(int i=n; i<100000; i++){
    int tmp=i, dig=log10(i)+1, flag=0;
    for(int j=0; j<dig; j++){
      if(b[tmp%10]==1) {
        flag=1;
        continue;
      }
      tmp/=10;
    }
    if(flag==0){
      cout << i;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    int A[N+10];REPP(i,1,N+1) cin >> A[i];
    int B[N+10] = {};
    repp(i,N+1,1){
        if(i > N/2){
            B[i] = A[i];
        }
        else{
            if(A[i] == 1 && B[i] % 2 == 1) B[i] = 0;
            else if(A[i] == 1 && B[i] % 2 == 0) B[i] = 1;
            else if(A[i] == 0 && B[i] % 2 == 1) B[i] = 1;
            else if(A[i] == 0 && B[i] % 2 == 0) B[i] = 0;
        }

        if(B[i] == 1 && i != 1){
            for(int j = 1;j*j <= i;++j){
                if(i % j == 0){
                    B[j]++;if(j != 1 && i/j != j) B[i/j]++;
                }
            }
        }
    }
    int cnt = 0;
    REPP(i,1,N+1) if(B[i] == 1) cnt++;
    cout << cnt << endl;
    REPP(i,1,N+1){
        if(B[i] == 1) cout << i << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 2560
def solve(a, op, b):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    elif op == '*':
        return a * b
    elif op == '/':
        return a // b
    return None

if __name__ == '__main__':
    while True:
        a, op, b = input().split()
        if op == '?': break
        print(solve(int(a), op, int(b)))

Measured memory_bytes: 6724
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 998244353
#define F first
#define S second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n ;
    cin >> n ;
    vector<ll> dp(n+1) , h(n+1);
    rep( i , 1 , n + 1 )
        cin >> h[i] ;
    dp[n]=0;
    dp[n-1]=abs(h[n]-h[n-1]);
    dp[n-2]=min(abs(h[n]-h[n-2]),abs(h[n-1]-h[n-2])+dp[n-1]);
    for(ll i = n - 3 ; i >= 1 ; i-- )
    {
        dp[i] = min( dp[i+1] + abs(h[i]-h[i+1]) , dp[i+2] + abs(h[i]-h[i+2]));
    }
    cout << dp[1] ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 1792