akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
ll n,m;
int main()
{
	IOS;
	string s1="ABC",s2="ARC",s;
	cin>>s;
	if(s==s1)
	cout<<s2;
	else
	cout<<s1;
}



Measured memory_bytes: 3640
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    flag = True
    for j in range(M):
        s = ks[j][1:]
        count = 0
        for v in s:
            if i & (1<<(v-1)):
                count += 1
        if count % 2 != p[j]:
            flag = False
    
    if flag:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	vector<pair<pair<string,int>,int>> vect(n);
	for(i=0;i<n;i++)
	{
		cin>>vect[i].first.first;
		cin>>vect[i].first.second;
		vect[i].first.second*=-1;
		vect[i].second=i;
	}
	sort(vect.begin(),vect.end());
	for(i=0;i<n;i++)
	{
		cout<<vect[i].second+1<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
s=input()
if len(s)<26:
    for i in range(26):
        c=chr(ord("a")+i)
        if c not in s:
            print(s+c)
            exit()
else:
    for i in reversed(range(1,26)):
        if s[i-1]<s[i]:
            s1=s[0:i-1]
            for j in range(26):
                c=chr(ord("a")+j)
                if c > s[i-1] and c not in s1:
                    print(s1+c)
                    exit()
    print(-1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=200010;
vector<int> a[N];
ll n, m;
int main(){
	int t;
	scanf("%lld",&n);
	int x, y;
	ll ans=0;
	for(int i=0; i<n-1; ++i){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
		ans-=(n-max(y, x)+1)*(min(x, y));
	}
	for(int i=1; i<=n; ++i){
		ll tmp=n-i+1;
		ans+=tmp*(tmp+1)/2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15004
#include<iostream>
using namespace std;
int main(){
    int n,a;
    cin>>n;
    int rev[n];
    for(int i=1;i<=n;i++){
        cin>>a;
        int  value;
        rev[i]=a;
    }
    for(int i=n;i>=2;i--){
        cout<<rev[i]<<" ";
    }
    cout<<rev[1]<<endl;
    return 0;
}


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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> pairs(M);
	for (int i = 0; i < M; i++)
	{
		int L, R;
		cin >> L >> R;
		pairs[i] = make_pair(L, R);
	}
	
	int answer = 0;
	
	// Lの最大値
	int maxL = pairs[0].first;
	// Rの最小値
	int minR = pairs[0].second;
	
	for (int i = 1; i < M; i++)
	{
		maxL = max(pairs[i].first, maxL);
		minR = min(pairs[i].second, minR);
	}

	if (minR >= maxL)
	{
		// Rの最小 - Lの最大 + 1
		// 1枚の全てのゲートを通過できる ID カードの枚数が算出できる
		answer = minR - maxL + 1;
	}
	else {
		// 0以下にならないようにする
		answer = 0;
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, L;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> L;
    a.resize(n);
    ll sum = 0;
    for(auto &i : a){
        cin >> i;
        sum += i;
    }
    int idx = -1;
    for(int i = 0 ; i + 1 < n ; i++){
        if(a[i] + a[i + 1] >= L) idx = i;
    }
    if(idx == -1) finish("Impossible");
    cout << "Possible" << endl;
    idx++;
    for(int i = 1 ; i < idx ; i++){
        cout << i << "\n";
    }
    for(int i = n - 1 ; i > idx ; i--){
        cout << i << "\n";
    }
    cout << idx << endl;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans = 2019;
  LL L, R;
  cin >> L >> R;

  LL range = R - L + 1;
  if (range > 2019) {
    range = 2019;
  }

  FOR(i, 0, range) {
    FOR(j, i + 1, range) {
      LL modulo = (L + i) * (L + j) % 2019;
      ans = min(ans, modulo);
    }
  }

  cout << ans << '\n';

  return 0;
}

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

int main() {
    int64_t N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    enum {
        ROCK, PAPER, SCISSORS, FREE,
    };

    //i回目にjを出したときの最大得点
    vector<int64_t> hand;
    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        if (i < K) {
            if (T[i] == 'r') {
                hand.push_back(PAPER);
                ans += P;
            } else if (T[i] == 'p') {
                hand.push_back(SCISSORS);
                ans += S;
            } else {
                hand.push_back(ROCK);
                ans += R;
            }
        } else {
            if (T[i] == 'r') {
                if (hand[i - K] == PAPER) {
                    hand.push_back(FREE);
                } else {
                    hand.push_back(PAPER);
                    ans += P;
                }
            } else if (T[i] == 'p') {
                if (hand[i - K] == SCISSORS) {
                    hand.push_back(FREE);
                } else {
                    hand.push_back(SCISSORS);
                    ans += S;
                }
            } else {
                if (hand[i - K] == ROCK) {
                    hand.push_back(FREE);
                } else {
                    hand.push_back(ROCK);
                    ans += R;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,m,d;
  cin >> n >> m >> d;
  if(d==0){
    cout << setprecision(10) << (m-1)/n << endl;
  }
  else{
    cout << setprecision(10) << (m-1)/n*2*(n-d)/n << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner (System.in);
    int N = sc.nextInt();
    int[] array = new int[N];
    for (int i=0; i<N; i++) {
      int key = sc.nextInt();
      array[key-1] = i+1;
    }
    for (int j=0; j<N; j++)
      System.out.println(array[j]);
  }
}

Measured memory_bytes: 60544
import numpy as np

import numpy as np

N, C = map(int, input().split(' '))
s = []
t = []
c = []
for i in range(N):
    s_i, t_i, c_i = map(int, input().split(' '))
    s.append(s_i)
    t.append(t_i)
    c.append(c_i - 1)
T = 2*max(t)
# for i in range(N):
#     table[2*s[i]-1: 2*t[i]] += 1
table = np.zeros(T)
for i in range(C):
    table_i = np.zeros(T)
    for j in range(N):
        if c[j] == i:
            table_i[2*s[j]-1: 2*t[j]] = 1
    table += table_i
print(int(np.max(table)))


Measured memory_bytes: 27448
S = list(input())

import copy
cnt = 0
for i in range(2 ** (len(S)-1)):
    op = []
    for j in range((len(S)-1)):
        if ((i >> j) & 1):
            op.append(j)

    S_copy = copy.deepcopy(S)
    for idx, k in enumerate(op):
        S_copy.insert(k+1+idx, '+')
    cnt += eval(''.join(S_copy))

print(cnt)

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	int ans = N * N * N;

	cout << ans << endl;

	return 0;
}


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

int dp[1000000] = {};

int is_prime(int n) {
  if (n==1) {
    return 0;
  }
  for (int i=2; i*i<=n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}

int main() {
  int n;
  for (int i=2; i<= 1000000; i++) {
    if (is_prime(i)) {
      dp[i] = dp[i-1] + 1;
    }
    else {
      dp[i] = dp[i-1];
    }
  }
   
  while(cin>>n) {
    cout << dp[n] << endl;
  }
}




Measured memory_bytes: 6904
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <bitset>
#include <regex>
#include <cassert>
#include <set>
#include <map>
using namespace std;
#define inf 2000000000
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(1){
		c -= b;
		if(c<=0){
			cout << "Yes";
			break;
		}
		a-=d;
		if(a<=0) {
			cout << "No";
			break;
		}
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {
	UL P[200000];

	void Solve() {
		UL N; cin >> N;
		rep(i, N)cin >> P[i];
		UL M = 1000000;
		UL ans = 0;
		rep(i, N) {
			M = min(M, P[i]);
			if (P[i] <= M) ans++;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1024
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    dp = [10**18]*n
    dp[0] = 0
    for i in range(1, n):
        for j in range(i-1, max(i-k-1, -1), -1):
            dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]))
    print(dp[-1])

Measured memory_bytes: 86640
var
	N,i,id,sz,asz,t:Longint;
	pa,x,ans:Array[1..1000]of Longint;
	dp:Array[1..1000]of int64;
	cum:Array[0..1]of int64;
	cumpa:Array[0..1]of Longint;
begin
	read(N);
	id:=1;
	for i:=1 to N do begin
		read(dp[i]);
		pa[i]:=0;
		t:=i and 1;
		if cum[t]>0 then begin
			inc(dp[i],cum[t]);
			pa[i]:=cumpa[t];
		end;
		if dp[i]>cum[t]then begin
			cum[t]:=dp[i];
			cumpa[t]:=i;
		end;
		if dp[id]<dp[i]then id:=i;
	end;
	writeln(dp[id]);
	while id>0 do begin
		inc(sz);
		x[sz]:=id;
		id:=pa[id];
	end;
	for i:=N downto x[1]+1 do begin
		inc(asz);
		ans[asz]:=i;
	end;
	for i:=2 to sz do begin
		t:=(x[i-1]-x[i])div 2;
		while t>0 do begin
			inc(asz);
			ans[asz]:=x[i]+t;
			dec(t);
		end;
	end;
	for i:=1 to x[sz]-1 do begin
		inc(asz);
		ans[asz]:=1;
	end;
	writeln(asz);
	for i:=1 to asz do writeln(ans[i]);
end.

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	llint n,a,b,s,ans=0;
	cin >> n >> a >> b;
    s = a+b;
    ans = (n/s)*a;
    if(n%s<a){
     	ans = ans + n%s; 
    } else{
       ans = ans + a;
    }

	cout << ans;   
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int ma=0,mb=0;
	string s;
	cin >> s;
	string d = s.substr(0, 2);
	if (stoi(d) < 13 && stoi(d) > 0)ma++;
	else ma = 0;
	string f = s.substr(2, 2);
	if (stoi(f) < 13 && stoi(f) > 0)mb++;
	else mb = 0;
	if (ma == 0 && mb == 0)cout << "NA" << endl;
	else if (ma == 1 && mb == 0)cout << "MMYY" << endl;
	else if (ma == 0 && mb == 1)cout << "YYMM" << endl;
	else cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    vec B(N); cin >> B;

    pairs pa(N), pb(N);
    REP(i, N){
        pa[i] = Pii(A[i], i);
        pb[i] = Pii(B[i], i);
    }
    Sort(pa); Sort(pb);

    REP(i, N) if(pa[i].f > pb[i].f){
        Out("No");
        return 0;
    }

    vec e(N);
    REP(i, N) e[pa[i].s] = pb[i].s;
    bool ans = false;

    int n = 0, now = 0;
    do{
        now = e[now];
        n++;
    }while(now != 0);
    if(n < N) ans = true;

    REP(i, N - 1) if(pa[i + 1].f <= pb[i].f) ans = true;

    Ans(ans, "Yes", "No");

    return 0;
}


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

using namespace std;

int main() {
	int n; 
	cin >> n;
	vector<int> a(n);
	for (int &x : a) cin >> x;

	int m = 0;
	for (int i = 0; i < n; i++) {
		if (a[m] > a[i]) {
			m = i;
		}
	}

	cout << m + 1 << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <map>


using namespace std;

int main(void) {

	string S;

	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy";
	}
	else if (S == "Cloudy") {
		cout << "Rainy";
	}
	else if (S == "Rainy") {
		cout << "Sunny";
	}

	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = list(input() for _ in range(h))
ans = [[""]] * (h+2)
ans[0], ans[-1] = ["#"] * (w+2), ["#"] * (w+2)
for i in range(1, h+1):
    ans[i] = ["#" + a[i-1] + "#"]
for a in ans:
    print("".join(a))

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

int main() {
	int r = 0, b = 0,n;
	char s[111];
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			r++;
		else
			b++;
	}
	if (r > b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		long ans = 0;
		if(n > k){
			for(int i = 0; i < n - k; i++){
				ans += h[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 64652
use std::cmp;
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 read_str() -> Vec<char> {
    return read::<String>().chars().collect();
}

#[allow(non_snake_case)]
fn is_ATGC_char(c: &char) -> bool {
    "ATGC".chars().collect::<Vec<char>>().contains(c)
}


fn solve3(b: &Vec<char>) -> usize {
    let (_, max_len) = b.iter().fold((0, 0), |(len, max), c| {
        if is_ATGC_char(c) {
            (len + 1, cmp::max(len + 1, max))
        } else {
            (0, max)
        }
    });
    max_len
}
pub fn main() {
    let b = read_str();
    println!("{}", solve3(&b));
}


Measured memory_bytes: 4476
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <queue>
#include <string>

using namespace std;

const double PI = 3.14159265358979;



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

	int C[21];
	for (int i = 0; i < m; i++)	{
		cin >> C[i];
	}

	int dp[50001];
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i] = INT_MAX;
	}

	for (int i = 1; i <= n; i++) {	// 1 2 7 8 12                  
		for (int j = 0; j < m; j++)	{	//	1 1 2 
			if (i >= C[j])
				dp[i] = min(dp[i], dp[i - C[j]] + 1);
		}
	}
	cout << dp[n] << endl;

	return 0;
}



Measured memory_bytes: 3308
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var ret0 = culc0m(a);
        var ret1 = culc0p(a);
        Console.WriteLine(Math.Min(ret0,ret1));
    }
    public static long culc0m(long[] a)
    {
        var count = 0L;
        var sum = a[0];
        if (sum >= 0) { count += sum + 1; sum = -1; }
        for (int i = 1; i < a.Length; i++)
        {
            if (i % 2 == 1)
            {
                if (sum + a[i] > 0) sum += a[i];
                else { count += -(sum + a[i]) + 1; sum = 1; }
            }
            else
            {
                if (sum + a[i] < 0) sum += a[i];
                else { count += (sum + a[i]) + 1; sum = -1; }
            }
        }
        return count;
    }
    public static long culc0p(long[] a)
    {
        var count = 0L;
        var sum = a[0];
        if (sum <= 0) { count += -sum + 1; sum = 1; }
        for (int i = 1; i < a.Length; i++)
        {
            if (i % 2 == 1)
            {
                if (sum + a[i] < 0) sum += a[i];
                else { count += (sum + a[i]) + 1; sum = -1; }
            }
            else
            {
                if (sum + a[i] > 0) sum += a[i];
                else { count += -(sum + a[i]) + 1; sum = 1; }
            }
        }
        return count;
    }
}

Measured memory_bytes: 27228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>

int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  vector<int> r;
  if(s[0]=='0') r.push_back(0);
  bool f0=1,f1=1;
  int tmp=0;
  rep(i,n){
    if(s[i]=='0'){
      if(f0) {tmp++; f1=0;}
      else {r.push_back(tmp); tmp=1; f1=0, f0=1;}
    }
    if(s[i]=='1'){
      if(f1) {tmp++; f0=0;}
      else {r.push_back(tmp); tmp=1; f1=1, f0=0;}
    }
  }
  r.push_back(tmp);
  if(s[n-1]=='0') r.push_back(0);
  vector<int> a(r.size()+1);
  a[0]=0;
  rep(i,r.size()){
    a[i+1]=a[i]+r[i];
  }
  int ans=0;
  if(k>=r.size()/2) ans=n;
  else{
    for(int i=2*k+1; i<a.size(); i+=2){
      ans=max(ans,a[i]-a[i-(2*k+1)]);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
 
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES\n";
    else cout<<"NO\n";

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    string t[4] = {"dreamer", "eraser", "dream", "erase"};
    cin >> s;
    while(s.size()){
        bool f = true;
        rep(i, 0, 4){
            if(s.size() < t[i].size()) continue;
            if(s.substr(s.size() - t[i].size()) == t[i]){
                // cout << s.substr(s.size() - t[i].size()) << " " << t[i] << endl;
                s = s.substr(0, s.size() - t[i].size());
                f = false;
            }
        }
        if(f) break;
    }
    if(s == "") cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int A[n], dp[n];
    for(int i = 0;i < n;++i){
        cin >> A[i];
        dp[i] = 0;
    }
    dp[1] = abs(A[1] - A[0]);
    for(int i = 2; i < n;++i){
        dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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


int main()
{
	char c[11];
	int n, k;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	cin >> k;
	for (int i = 1; i <= n; i++) {
		if (c[i] == c[k])cout << c[k];
		else cout << "*";
	}
	cout << endl;
}

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



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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    sort(v.begin(), v.end());
    pair<int, int> a = {v[0].first, v[0].second};
    bool ok = true;
    for (int i = 1; i < m; i++)
    {
        if (v[i].first > a.second)
        {
            ok = false;
            break;
        }
        else
        {
            a.first = max(a.first, v[i].first);
            a.second = min(a.second, v[i].second);
        }
    }
    if (!ok) cout << 0 << endl;
    else cout << a.second - a.first + 1 << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  map<ll, ll> mp;
  ll N,K;
  IN(N,K);

  REP(i,N){
    ll a, b;
    IN(a,b);
    if(mp.find(a)==mp.end()){
      mp[a] = b;
    }else{
      mp[a] += b;
    }
  }

  for(auto itr : mp){
    K -= itr.second;
    if(K<=0){
      OUT(itr.first);
      return 0;
    }
  }

  return 0;
}

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

int main(int argc, char const *argv[])
{
	long long A, B, C, K;
	cin >> A >> B >> C >> K;
	if(K & 1) {
		cout << (B - A) << endl;
	} else {
		cout << (A - B) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' #use a string like this, instead of ord()
N = int(input().strip())
def shifttext(shift):
    S = str(input('').upper()) #Input text here
    data = []
    for i in S: #iterate over the text not some list
        if i.strip() and i in alphabet: # if the char is not a space ""
            data.append(alphabet[(alphabet.index(i) + shift) % 26])
        else:
            data.append(i) #if space the simply append it to data
    output = ''.join(data)
    return output
print(shifttext(N))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define mk make_pair
#define ll long long
#define int long long

using namespace std;

inline int read()
{
  int x=0,f=1;char ch=getchar();
  while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
  while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}

const int maxn = 4e5+1e2;

int a[maxn];
int n,len;
int mx,mx1;
int sum[maxn];

int solve(int l,int r)
{
	int now = a[l];
	//if(now==0)now=len;
	l++;
	int ans=0;
	int flag=1;
	int rest=r-l+1;
	while (rest)
	{
		if(flag)
		{
			ans=ans+len-a[r]+now;
			flag^=1;
			now=a[r];
			r--;
			rest--;
		}
		else
		{
			ans=ans+len-now+a[l];
			flag^=1;
			now=a[l];
			l++;
			rest--;
		}
	//	cout<<ans<<"****"<<endl;
	}
	return ans;
}

int solve1(int l,int r)
{
	int now = a[r];
	r--;
	if(now==0) now=len;
	int ans=0;
	int flag=0;
	int rest=r-l+1;
	while (rest)
	{
		if(flag)
		{
			ans=ans+len-a[r]+now;
			flag^=1;
			now=a[r];
			r--;
			rest--;
		}
		else
		{
			ans=ans+len-now+a[l];
			flag^=1;
			now=a[l];
			l++;
			rest--;
		}
	//	cout<<ans<<"****"<<endl;
	}
	return ans;
}

int s[maxn];

int gets(int l,int r)
{
	return s[r]-s[l-1];
}

int getsum(int l,int r)
{
	return sum[l]-sum[r+1];
}

int count(int l,int r)
{
	int ans = 0;
	int now = r-l+1;
	if (now&1)
	{
		int mid = l+now/2;
		//cout<<gets(l,mid)<<" "<<getsum(mid+1,r)<<" "<<a[mid]<<endl;
		return gets(l,mid)+getsum(mid+1,r)-a[mid];
	}
	else
	{
		int mid = l + now/2;
		return gets(l,mid-1)+getsum(mid,r)-(len-a[mid]);
	}
}

signed main()
{
  len=read(),n=read();
  for (int i=1;i<=n;i++) a[i]=read(),sum[i]=(len-a[i])*2,s[i]=2*a[i];
  for (int i=1;i<=n;i++) s[i]+=s[i-1];
  for (int i=n;i>=1;i--) sum[i]+=sum[i+1];
  int ans=0;
  for (int i=1;i<=n;i++)
  {
  	 int tmp=0;
  	 ans=max(ans,count(i,n));
  	 //cout<<ans<<"***"<<endl;
  }
  memset(sum,0,sizeof(sum));
  memset(s,0,sizeof(s));
  for (int i=1;i<=n;i++) a[i]=len-a[i];
  sort(a+1,a+1+n);
  for (int i=1;i<=n;i++) sum[i]=(len-a[i])*2,s[i]=2*a[i]; 
  for (int i=1;i<=n;i++) s[i]+=s[i-1];
  for (int i=n;i>=1;i--) sum[i]+=sum[i+1];
  for (int i=1;i<=n;i++)
  {
  	 int tmp=0;
  	 ans=max(ans,count(i,n));
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef  long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define F first
#define S second
#define pi 3.141592653589793238
#define INF 1e9+5


int main()
{

	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll dp[n+5];
	for(int x=0;x<n;x++){
     	   cin>>a[x];
     	   dp[x]=INF;
	}
	dp[0]=0;
	for(int x=0;x<n;x++){
        for(int y=x+1;y<=x+k;y++){
            if(y<n){
              dp[y]=min(dp[y],dp[x]+abs(a[x]-a[y]));
            }
        }
	}
	cout<<dp[n-1];

}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
  int n, one, two, three;

  scanf("%d", &n);

  while(n!=0){
    scanf("%d %d %d", &one, &two, &three);

    if((one*one)+(two*two)==(three*three)){
      printf("YES\n");
    }else if((one*one)+(three*three)==(two*two)){
      printf("YES\n");
    }else if((two*two)+(three*three)==(one*one)){
      printf("YES\n");
    }else{
      printf("NO\n");
    }

    n--;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
    int *a=new int[206]{0};
    int *b=new int[206]{0};
    int sum=0;
    int x,y;
    a[0]=300000;
    a[1]=200000;
    a[2]=100000;
    b[0]=300000;
    b[1]=200000;
    b[2]=100000;
    cin>>x>>y;
    sum=a[x-1]+b[y-1];
    if (x==1&&y==1)
        sum+=400000;
        cout<<sum;
}
int main(){
    solve();
    return 0;
}

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

class program
{
  static void Main(string[] args)
  {
    int n = Convert.ToInt16(Console.ReadLine());
    List<List<int>> lst = new List<List<int>>();
    for (int i = 0; i < n; i++)
    {
      lst.Add(new List<int>());
    }

    int i_target = 0;
    int i_tCnt = 0;
    int start = (n % 2 != 0 ? n - 1 : n);
    for (int i = start; i > 0; i--)
    {
      i_target = i;

      for (int j = 1; j <= i; j++)
      {
        if (calc(i_target))
        {
          lst[i - 1].Add(j);
          break;
        }
        i_target = i_target / 2;
      }
      i--;
    }

    int count = 0;
    int num = 0;
    for (int i = 0; i < lst.Count; i++)
    {
      if (lst[i].Count > 0)
      {
        if (count < lst[i][0])
        {
          count = lst[i][0];
          num = i + 1;                
        }
      }
    }
    
    if (num == 0)
    {
      num = n;
    }

    Console.WriteLine(num);
  }

  public static bool calc(int i)
  {
    bool ret = true;
    if (i % 2 == 0)
    {
      ret = false;
    }
    return ret;
  }
}

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/
string s;
int K;

signed main() {
    cin >> s >> K;
    set<string> a;
    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < 5 && i + j < s.length(); j++) {
            a.insert(s.substr(i, j + 1));
        }
    }
    vector<string> pq;
    for (auto itr = a.begin(); itr != a.end(); ++itr) {
        pq.push_back(*itr);
    }
    sort(pq.begin(), pq.end());
    cout << pq[K - 1] << endl;
}

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

int ab[51][2] = {0};
int ans[51] = {0};

int main() {
  int N = 0, M = 0;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> ab[i][0] >> ab[i][1];
  }
  
  for (int i = 0; i < M; i++) {
    ans[ab[i][0] - 1]++;
    ans[ab[i][1] - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
D,G=map(int,input().split())
A=[]
for i in range(D):
    p,c=map(int,input().split())
    A.append([p,c])
a=10**9
for j in range(2**D):
    b=format(j, 'b')
    B="0"*(D-len(b))+str(b)
    S=[]
    N=[]
    for k in range(D):
        S.append((A[k][0]*(k+1)*100+A[k][1])*int(B[-k-1]))
        N.append(A[k][0]*int(B[-k-1]))
        if sum(S)>=G:
            s=sum(N)
            if a>s:
                a=s
        else:
            for l in range(D):
                if B[l]=="0" and (G-sum(S))<=((D-l)*100)*(A[-l-1][0]-1):
                    s=sum(N)+((G-sum(S))//((D-l)*100))+min(1,((G-sum(S))%((D-l)*100)))
                    if a>s:
                        a=s
                    break
print(a)

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;

  reverse(s.begin(), s.end());
  
  ll ans = 0;
  ll b = 0;
  ll w = 0;
  for (ll i = 0; i < n; ++i) {
    if (s[i] == '#' && w == 0) continue;
    
    if (b > 0 && w > 0 && s[i] == '.') {
      if (w < b) {
        ans += w;
        b = 0;
        w = 0;
      }
    }
    if (s[i] == '#') ++b;
    else ++w;
  }

  if (b > 0 && w > 0) {
    ans += min(b, w);
  }

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


Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    if(a < b){
        ll temp = a;
        a = b;
        b = temp;
    }
    return (b ? gcd(b, a % b) : a);
}

int main(){
    int n; cin >> n;
    ll ans = 1;
    for(int i = 0; i < n; ++i){
        ll t; cin >> t;
        ans /= gcd(ans, t);
        ans *= t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner a = new Scanner(System.in);
    int f = a.nextInt();
    String s = String.valueOf(f);
    for(int i = 0; i < s.length(); i++){
      if(Character.getNumericValue(s.charAt(i)) == 7){
        System.out.println("Yes");
        break;
      }else if(i == s.length()-1 && Character.getNumericValue(s.charAt(i)) != 7){
        System.out.println("No");
      }
    }
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+10;

vi edges[N];
vi inedges[N];
int indeg[N];
queue<int> q;
vi topo;
int dp[N];

int main(){
fast;
int n,m;
cin>>n>>m;
for(int i=0;i<=n;i++) {
    edges[i].clear();
    inedges[i].clear();
    indeg[i]=0;
    dp[i]=0;
}

for(int i=0;i<m;i++) {
    int u,v;
    cin>>u>>v;
    edges[u].push_back(v);
    indeg[v]++;
    inedges[v].push_back(u);
}

while (!q.empty())
q.pop();

for(int i=1;i<=n;i++) {
    if(indeg[i]==0) {
        q.push(i);
    }
}

topo.clear();
while (!q.empty()) {
    int v = q.front();
    q.pop();
    topo.push_back(v);
    for(int i=0;i<edges[v].size();i++) {
        indeg[edges[v][i]]--;
        if(indeg[edges[v][i]]==0) {
            q.push(edges[v][i]);
        }
    }
}

int ans=0;
for(int i=0;i<topo.size();i++) {
    dp[topo[i]]=0;
    for(int j=0;j<inedges[topo[i]].size();j++) {
        dp[topo[i]]=max(dp[topo[i]], 1+dp[inedges[topo[i]][j]]);
    }
    ans=max(ans, dp[topo[i]]);
}
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 20252
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
//a power n mod p
long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
 /*   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
   // cin>>t;
    lld n,i,j,ans,x3,x5,x15;
    string s;
    vector<vector<long long int > > v(3);
    cin>>n>>s;
    lld a[3];
    a[0]=a[1]=a[2]=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R') v[0].pb(i);
        else if (s[i]=='G') v[1].pb(i);
    }
    a[0]=v[0].size();
    a[1]=v[1].size();
    a[2]=n-a[0]-a[1];
    for(i=0;i<a[0];i++)
    {
        for(j=0;j<a[1];j++)
        {
            x= 2*v[1][j]-v[0][i];
            if(x>=0 && x<n)
            {
                if()
            }
        }
    }
   */
    lld n,i;
    cin>>n;
    for(i=0;i<3;i++)
    {
        if(n%10 == 7)
        {
             cout<<"Yes";
             return 0;
        }
        n/=10;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e5 + 7;

ll x; vii a ,b;

int main()
{
    FASTIO// ONLINE__JUDGE();

    cin >> x; a.resize( x+5 ); b.resize( x+5 );
    for ( int i = 1; i <= x; ++i ){
        a[i] = i; cin >> b[i];
    }
    ll cnt = 0;
    for ( int i = 1; i <= x; ++i ){
        if ( a[i] != b[i] ) cnt++;
    }

    if ( cnt <= 2 ){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b, c, temp;
	scanf("%d%d%d", &a, &b, &c);

	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}
	if (b > c) {
		temp = c;
		c = b;
		b = temp;
	}
	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}

	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 1e4+5;
 
string s;
 
int main()
{
	cin >> s;
	rep(i, 0, s.length()){
		putchar('x');
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
set<int>mp;
ll qq[10];
ll mu[10];
int main()
{
    ll time=0,n;
    memset(mu,0,sizeof(mu));
    mu[0]=n;
    cin>>n;
    for(ll i=0; i<5; i++)
        cin>>qq[i];
    sort(qq,qq+5);
    n=(n+qq[0]-1)/qq[0];
    n=n+4;
    cout<<n;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

int main(){

	int a,b,c;

	cin>>a>>b>>c;

	if(a<=c && c<=b){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main() {
	long long n;
	cin >> n;
	
	long long best = 0;
	long long curr = 0;
	
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			long long mul = n / i;
			
			long long digs_i = floor(log10(i) + 1);
			long long digs_mul = floor(log10(mul) + 1);
			
			curr = max(digs_i, digs_mul);
			best = max(best, curr);
		}
	}
	
	cout << curr << endl;
		
}

Measured memory_bytes: 3868
h, w, k = map(int, input().split())
cakes = []
for _ in range(h):
    row = list(input())
    cakes.append(row)

# 左から埋める
c = 1
for i in range(h):
    for j in range(w):
        if cakes[i][j] == '#':
            cakes[i][j] = c
            for k in range(0, j):
                if cakes[i][k] == '.':
                    cakes[i][k] = c
            c += 1

# 右側に残っているモノを、一番左のモノで埋める。
for i in range(h):
    for j in range(w):
        if cakes[i][j] == '.':
            cakes[i][j] = cakes[i][j - 1]

#上下を埋める
for i in range(1, h):
    for j in range(w):
        if cakes[i][j] == '.':
            cakes[i][j] = cakes[i - 1][j]
for i in range(h - 1)[::-1]:
    for j in range(w):
        if cakes[i][j] == '.':
            cakes[i][j] = cakes[i + 1][j]

for r in cakes:
    print(*r)

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

int main() {
    int N;
    cin >> N;

    vector<int> a(N, 0);
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i] - 1;
    }

    cout << sum << endl;

}

Measured memory_bytes: 256