akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long

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

	int first = 7;
	for (int i = 1; i <= 1e7 ; i++) {
		if (first % k == 0) {
			cout << i << endl;
			return 0;
		}
		first = ((first * 10) + 7 ) % k ;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

bool cmp(pair<int, int> &x, pair<int, int> &y)
{
	return x.second > y.second;
}

int main(void)
{
	int n, m;
	while(cin >> n >> m, n > 0){
		int j = 0, ans = 0;
		vector<pair<int, int>> dp(n);
		rep(i, n){
			int d, p;
			cin >> d >> p;
			dp[i] = make_pair(d, p);
		}
		sort(dp.begin(), dp.end(), cmp);
		while(m > 0){
			if (dp[j].first > 0){
				dp[j].first--;
				m--;
			}else{
				j++;
				if (j == n) break;
			}
		}
		rep(i, n){
			ans += dp[i].first * dp[i].second;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3196
#include <iostream>

int main() {
    int n, m, x; std::cin >> n >> m >> x;
    int r = 0;
    int l = 0;
    for (int i = 0; i < m; i++) {
        int a; std::cin >> a;
        ((a < x)?l:r) += 1;
    }
    std::cout << std::min(l, r) << std::endl;
    return 0;
}

Measured memory_bytes: 3144
#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;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vector <pll> adj[MAX];
ll c[MAX];
bool vis[MAX];
void dfs(ll cur, ll p)
{
    if(!vis[cur])
    {
        vis[cur] = 1;
        c[cur] = p;
        for(auto x : adj[cur])
        {
            dfs(x.F, (p + x.S) % 2);
        }
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, u, v, w;
    cin >> n;
    for(i = 0; i < n - 1; i++)
    {
        cin >> u >> v >> w;
        adj[u].pb({v, w});
        adj[v].pb({u, w});
    }
    dfs(1, 0);
    for(i = 1; i <= n; i++)
        cout << c[i] << endl;
    return 0;
}

Measured memory_bytes: 31232
import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	}

}


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

using namespace std;

int main()
{
string S;
int t =0;
for(int i =0; i<4; i++)
   {

cin >> S[i];

 if (S[i]=='+')
    t++;
    else
    if(S[i]=='-')
        t--;
}
cout << t;



    return 0;
}


Measured memory_bytes: 256
import math
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

n_list = []
for i in range(1, n+1):
    n_list.append(i)

junretu = list(itertools.permutations(n_list))
sorted(junretu)
idx_p = 0
idx_q = 0
for i in range(math.factorial(n)):
    if list(junretu[i]) == p:
        idx_p = i
    if list(junretu[i]) == q:
        idx_q = i
    elif idx_p != 0 and idx_q != 0:
        break

print(abs(idx_q - idx_p))


Measured memory_bytes: 45808
A=int(input())
shop_l=[list(map(int,input().split())) for i in range(A)]
shop_count_l=[list(map(int,input().split())) for i in range(A)]
ans=-1*10**10
for i in range(1,1024):
   tmp=0
   l=[0]*A
   for j in range(10):
      if (i>>j)&1:
         for k in range(A):
            if shop_l[k][j] == 1:
               l[k]+=1
   for i in range(A):
      tmp+=shop_count_l[i][l[i]]
   ans=max(ans,tmp)
print(ans)

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

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

#define NL '\n'
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x, y) scanf("%d%d",&x, &y)
#define sll(x, y) scanf("%lld%lld",&x, &y)

#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define mdx ((l+r)>>1)
#define ldx ((idx<<1))
#define rdx ((idx<<1)|1)
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define file_err(); freopen("serr.txt", "w", stderr);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

template<class T> T setbit(T n, T pos){n=n|(1<<pos); return n;}
template<class T> T checkbit(T n, T pos){n=n&(1<<pos); return n;}
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return ((a / gcd(a,b) ) * b);}





const int mxx = 1e5+9;
int n, a[mxx], dp[mxx];

int main(){
	_fastIO();
	rep(i, 0, mxx) dp[i] = INT_MAX;
	dp[0] = 0;
	cin >> n; 
	rep(i, 0, n) cin >> a[i];
	rep(i, 1, n){
		if(i - 1 >= 0) dp[i] = min(dp[i], abs(a[i-1]-a[i]) + dp[i-1]);
		if(i - 2 >= 0) dp[i] = min(dp[i], abs(a[i-2]-a[i]) + dp[i-2]);
	}
	cout << dp[n-1] << NL;
}

Measured memory_bytes: 1024
n,m = map(int, input().split())
sc = {}
flag = True
for i in range(m):
		s,c = map(int, input().split())
		if s not in sc:
			sc[s]= c
		else:
			if sc[s] != c:
				flag = False

if flag == False:
	print(-1)
	exit()

if n ==1 :
	if (2 in sc) or (3 in sc):
		print(-1)
		exit()
	if 1 in sc:
		print(sc[1])
	else:
		print(0)

if n==2:
	if 3 in sc:
		print(-1)
		exit()
	if 1 in sc:
		if sc[1] == 0:
			print(-1)
			exit()
		elif 2 in sc:
			print(str(sc[1]) + str(sc[2]))
		elif 2 not in sc:
			print(str(sc[1]) +str(0))
	else:
		if 2 in sc:
			print(str(1) + str(sc[2]))
		else:
			print(10)

if n==3:
	if 1 in sc:
		if sc[1] == 0 :
			print(-1)
			exit()
		elif 2 in sc and 3 in sc:
			print(str(sc[1])+ str(sc[2]) +str(sc[3]))
		
		elif 2 in sc and 3 not in sc:
			print(str(sc[1])+ str(sc[2])+str(0))
		
		elif 2 not in sc and 3 in sc:
			print(str(sc[1]) + str(0) + str(sc[3]))
		else:
			print(str(sc[1]) + "00")
	else:
		if 2 in sc and 3 in sc:
			print(str(1)+ str(sc[2]) +str(sc[3]))
		
		elif 2 in sc and 3 not in sc:
			print(str(1)+ str(sc[2])+str(0))
		
		elif 2 not in sc and 3 in sc:
			print(str(1) + str(0) + str(sc[3]))
		else:
			print(100)





Measured memory_bytes: 3316
a = [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]
b = int(input()) - 1
print(a[b])


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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

    if (n >= 10) { cout << r << endl; }
    else { cout << r + 100 * (10 - n) << endl; }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
  return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//mod add
void add (ll &a, ll b){
  a += b;
  if (a >= MOD) a -= MOD;
}

// 0: dammy, 1: 'A', 2: 'G', 3: 'C'. 4: 'T'
// "AGC, GAC, ACG", "A*GC", "AG*C"　を含まない (012, 102, 021　を禁止)
ll solve(int N){
  auto dp = make_vec<ll>(N+1, 5, 5, 5); // dp[i文字][3文字前][2文字前][1文字前]
  dp[0][0][0][0] = 1;
  rep(n,N){
    rep(i,5){
      rep(j,5){
        rep(k,5){
          reps(l,4){
            if (i == 1 && j == 2 && l == 3) continue;
            if (i == 1 && k == 2 && l == 3) continue;
            if (j == 1 && k == 2 && l == 3) continue;
            if (j == 2 && k == 1 && l == 3) continue;
            if (j == 1 && k == 3 && l == 2) continue;
            add(dp[n+1][j][k][l], dp[n][i][j][k]);
          }
        }
      }
    }
  }
  ll res = 0;
  reps(i,4){
    reps(j,4){
      reps(k,4){
        add(res, dp[N][i][j][k]);
      }
    }
  }
  return res;
}

int main(){
  int N;  cin >> N;
  cout << solve(N) << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin>> N;
	int l=0,r=N-1;
	string s,t;
	cout<< 0<< endl;
	cin>> t;
	if(t=="Vacant")return 0;
	while(l!=r)
	{
		int i=(l+r+1)/2;
		cout<< i<< endl;
		cin>> s;
		if(s=="Vacant")return 0;
		if((t==s&&i%2)||(t!=s&&!(i%2)))r=i-1;
		else l=i;
	}

	return 0;
}


Measured memory_bytes: 852
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        if(n < 10){
            ans = n;
        }else if(10 <= n && n < 100){
            ans = 9;
        }else if(100 <= n && n < 1000){
            ans = 10 + (n-100);
        }else if(1000 <= n && n < 10000){
            ans = 909;
        }else if(10000 <= n && n < 100000){
            ans = 910 + (n-10000);
        }else{
            ans = 90909;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21716
H, W = map(int, input().split())
lines = [input() for i in range(H)]

for i in range(W + 2):
    print("#", end="")
print("")

for i in range(H):
    print("#", end="")
    print(lines[i], end="")
    print("#")

for i in range(W + 2):
    print("#", end="")
print("")


Measured memory_bytes: 3060
// abc174_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S_;
    cin >> S_;
    vector<char> S(N);
    int wcnt = 0;
    REP(i, N){
        S[i] = S_[i];
        if (S[i] == 'W'){
            wcnt++;
        }
    }

    int ans = 0;
    REP_REV(i, N){
        if (S[i] == 'R'){
            if (wcnt > 0){
                ans++;
                wcnt--;
            } else {
                break;
            }
        } else {
            wcnt--;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

int main(){
  long int a,b;
  cin >> a;
  long int min = 0,t;

  for(int i = 1; i <= sqrt(a);++i){

    if(a%i == 0){
      t = i-1+a/i-1;
      if(min == 0 || min > t){
        min = t;
      }
    }
  }




  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}


int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}


Measured memory_bytes: 2060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    ll sl = s.size();
    ll maxs = 0;
    int count = 1;
    int z = 1;
    string sub = s.substr(0, 1);
    for (int i = 1; i < sl; i++)
    {
        if (sub != s.substr(z, i - z + 1))
        {
            sub = s.substr(z, i - z + 1);
            count++;
            z = i + 1;
        }
    }
    cout << count << "\n";
}

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

using namespace std;
using ll = long long;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> f(n);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        f[x - 1].push_back(y - 1);
        f[y - 1].push_back(x - 1);
    }
    bool visited[n];
    for(int i = 0; i < n; i++) {
        visited[i] = 0;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(visited[i] == 1) {
            continue;
        }
        visited[i] = 1;
        queue<int> q;
        q.push(i);
        int cur = 1;
        while(q.empty() == 0) {
            for(int j = 0; j < f[q.front()].size(); j++) {
                if(visited[f[q.front()][j]] == 0) {
                    q.push(f[q.front()][j]);
                    visited[f[q.front()][j]] = 1;
                    cur++;
                }
            }
            q.pop();
        }
        if(ans < cur) {
            ans = cur;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 14964
#include<iostream>

using namespace std;

int main(void) {
    int n, left, right;
    cin >> n >> left >> right;

    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        int d = i;
        int dsum = 0;
        while (d > 0) {
            dsum += d % 10;
            d /= 10;
        }
        if (left <= dsum && dsum <= right) {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
vvl G(200005);
vl sum(200005,0);
bool visit[200005];
vl v(200005,0);

void bfs(ll s, ll n){
    queue<ll> q;
    q.push(s);
    sum[s] += v[s];
    while(!q.empty()){
        ll t = q.front(); q.pop();
        for(auto i : G[t]){
            sum[i] = sum[t] + v[i]; 
            q.push(i);
        }
    }
}
 
int main(){
    ll n; cin >> n;
    double sum = 0.0;
    rep(i,n){
        ll a; cin >> a;
        sum += 1 / (double)a;
    }
    cout << 1/sum << endl;
}

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

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator-() const { return MInt(-val); }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator-(const MInt& n) const { return MInt(val) -= n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator-=(const MInt& n) { val = (MOD + val - n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  bool operator==(const MInt& n) { return val == n.val; }
  bool operator!=(const MInt& n) { return val != n.val; }
  MInt pow(long long n) const {
    MInt pow = val, ans = 1;
    for (long long p = n; p > 0; p >>= 1) {
      if (p & 1) ans *= pow;
      pow *= pow;
    }
    return ans;
  }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
using mint = MInt<1000000007>;

int main() {
  int in(N); int in(K);

  vector<mint> dp(K+1);
  dp[K] = 1;
  mint ans = 0;
  rrep(gcd, K) {
    if (gcd == 0)
      break;
    dp[gcd] = K/gcd;
    dp[gcd] = dp[gcd].pow(N);

    for (int g = 2 * gcd; g <= K; g += gcd)
      dp[gcd] -= dp[g];

    ans += mint(gcd) * dp[gcd];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4044
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int n, ans, f[20000];
int main(){
	n=read();
	for (int x=1;x*x<n;x++)
		for (int y=1;y*y<n;y++)
			for (int z=1;z*z<n;z++)
				if (x*x+y*y+z*z+x*y+x*z+y*z<=n) f[x*x+y*y+z*z+x*y+x*z+y*z]++;
	for (int i=1;i<=n;i++) printf("%d\n", f[i]);
    return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return abs(a);
    return gcd(b, a % b);
}
int main() {
    string s; cin >> s;
    int check[26] = {0};
    rep(i, s.size()) check[s[i] - 'a']++;
    if (s.size() < 26) {
        cout << s;
        rep(i, 26) if (check[i] == 0) {cout << (char)('a' + i) << endl; break;}
    } else if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
    } else {
        int key;
        for (int i = (int)s.size() - 2; i >= 0; --i) {
            key = i;
            if (s[i] < s[i + 1]) break;
        }
        char mmin = 'z';
        rrep(i, key + 1, s.size()) {
            if (s[i] > s[key] && s[i] <= mmin) {
                mmin = s[i];
            }
        }
        //cout << mmin << endl;
        s[key] = mmin;
        rep(i, key + 1) cout << s[i];
        cout << endl;
    }
}



Measured memory_bytes: 256
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const [N, K] = input[0].split(" ").map(BigInt)
    const as = input[1].split(" ").map(n => Number(n));

    let loop = [0]
    let current = 0
    let loopStart = 0
    let visited = []
    for(let i = 0; i < K; i++) {
      current = as[current] - 1
      if (visited[current]) {
        loopStart = loop.indexOf(current)
        loop = loop.slice(loopStart)
        break
      }
      visited[current] = true
      loop.push(current)
    }
    console.log(loop[(K - BigInt(loopStart)) % BigInt(loop.length)] + 1)

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


Measured memory_bytes: 58400
def solve():
    from sys import stdin
    f_i = stdin

    n = int(f_i.readline())
    A = list(map(int, f_i.readline().split()))
    A.append(100000001)

    q = int(f_i.readline())

    from bisect import bisect_left
    ans = []
    for i in range(q):
        k = int(f_i.readline())
        if k == A[bisect_left(A, k)]:
            ans.append('1')
        else:
            ans.append('0')

    print('\n'.join(ans))


solve()



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

int main(){
  string s;
  int a=0;
  cin>>s;
  if(s=="SUN"){
    a=7;
  }
  if(s=="MON"){
    a=6;
  }
  if(s=="TUE"){
    a=5;
  }
  if(s=="WED"){
    a=4;
  }
  if(s=="THU"){
    a=3;
  }
  if(s=="FRI"){
    a=2;
  }
  if(s=="SAT"){
    a=1;
  }
  cout<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.2.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<", ";cout<<a.back()
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0 * 10^18 (MAXの1/3くらい)
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  Vi a(n);
  Vin(a);
  sort(ALL(a));
  
  deque<int> b;
  rep(i,1,n-1) b.pb(a[i]);
  
  int ans = a.back()-a[0];
  int nowa=a.back(),nowb=a[0];
  
  int qw,er,ty,ui,fr,ba,maxx;
  
  rep(i,1,n-1){
    fr = b.front();
    ba = b.back();
    
    qw = abs(fr-nowa);
    er = abs(ba-nowa);
    ty = abs(fr-nowb);
    ui = abs(ba-nowb);
    maxx = max({qw,er,ty,ui});
    
    if(maxx==qw){
      ans += qw;
      nowa = fr;
      b.pop_front();
    }
    else if(maxx==er){
      ans += er;
      nowa = ba;
      b.pop_back();
    }
    else if(maxx==ty){
      ans += ty;
      nowb = fr;
      b.pop_front();
    }
    else if(maxx==ui){
      ans += ui;
      nowb = ba;
      b.pop_back();
    }
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
inline ll min(ll x,ll y) {return x<y?x:y;}
inline ll max(ll x,ll y) {return x>y?x:y;}
const int Maxn=1e5+5;
char s[5];
int len;
int main()
{
	cin>>s+1;
	len=strlen(s+1);
	if(!(len&1))
		printf("%s\n",s+1);
	else
	{
		for(int i=len;i>=1;i--)
			printf("%c",s[i]);
		puts("");
	}	
 	return 0;
}


Measured memory_bytes: 256
#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;
    }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include <bits/stdc++.h>
using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define memo(dp, val) memset(dp, val, sizeof(dp))
#define NINJA                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define all(a) a.begin(), a.end()
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int n, x, m;

int step(int a) { return (a * a) % m; }

int32_t main() {
  NINJA;

  cin >> n >> x >> m;

  vector<int> vis(m, -1);
  vector<int> pre(2 * m);

  int ans = 0;

  for (int i = 1; i <= n; i++) {
    if (vis[x] >= 0) {
      int loopsize = i - vis[x];
      int loopsum = pre[i - 1] - pre[vis[x] - 1];
      int tot = (n - i) / loopsize;
      ans += tot * loopsum;
      i += tot * loopsize;
      for (int j = 0; j < vis.size(); j++)
        vis[j] = -1;
    }
    if (i < pre.size()) {
      pre[i] = pre[i - 1] + x;
      vis[x] = i;
    }
    ans += x;
    x = step(x);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5552
X = eval(input().strip())

if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
elif X < 2000:
    print(1)


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

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

  vector<int64_t> lucas(N+1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int i=2; i<=N; i++){
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }

  cout << lucas.at(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
using namespace std;

int main(){
  int H, W;
  int a[205][205], c[10][10];
  
  cin >> H >> W;
  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }

  for(int k = 0; k < 10; k++) {
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
	c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  long long ans = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(a[i][j] != -1)ans += c[a[i][j]][1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define LL long long
#define db double
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define PI acos(-1)
const ll mod=1e9+7;
int main()
{
    ll n;
    double d;
    cin >> n >> d;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        double x,y;
        scanf("%lf%lf",&x,&y);
        double s=sqrt(x*x+y*y);
        if(s<d || fabs(s-d)<=1e-6)
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
  int64_t N,M,K;
  cin>>N>>M>>K;
  vector<int64_t>A(N+1);
  vector<int64_t>B(M+1);
  A.at(0)=0;B.at(0)=0;
  for(int i=1;i<=N;i++){
  int64_t a;cin>>a;
    A.at(i)=A.at(i-1)+a;
  }for(int i=1;i<=M;i++){
  int64_t b;cin>>b;
    B.at(i)=B.at(i-1)+b;
  }int64_t ans=0;
  for(int i=0;i<=N;i++){
    if(A.at(i)<=K){
  auto itr=upper_bound(B.begin(),B.end(),K-A.at(i));
    int64_t c=distance(B.begin(),itr);
    if(ans<c+i-1)ans=i+c-1;}
    }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6428
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n, T,s=1000,k=1000,flag=0;
	cin >> n >> T;
	vector<pair<int,int>>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	//sort(p.begin(), p.end());
	for (int i = 0; i < n; i++) {
		if (p[i].second <= T) {
			s = min(p[i].second, s);
			k = min(p[i].first, k);
			flag = 1;
		}
		else if (i == n - 1&&flag==0) {
			cout << "TLE" << endl;
			exit(0);
		}
	}
	cout << k << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, x, y, z;
multiset < int > st;
int ans;

int main()
{

    cin >> n;
    for(int i = 1; i <= n; i++){
        int x;
        scanf("%d", &x);

        auto it = st.lower_bound(x);
        if(it == st.begin()){
            ans++;
            st.insert(x);
            continue;
        }

        it--;
        st.erase(it);
        st.insert(x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<ii> ar;
    int a, b;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> a >> b, ar.push_back(make_pair(a, -b));

    sort(ar.begin(), ar.end());
    int ctr0 = 0, rez = 0;
    priority_queue<int> pq;
    for (int ctr1 = 1; ctr1 <= m; ++ctr1) {
        while (ctr0 < ar.size() && ar[ctr0].first <= ctr1)
            pq.push(-ar[ctr0].second), ctr0++;
        if (!pq.empty())
            rez += pq.top(), pq.pop();
    }
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    string a,b;
    cin>>a>>b;
    int c=stoi(a+b);
    int f=0;
    for(int i=0;i<10000;i++)
    {
        if(i*i==c)
            {
                f=1;
                break;
            }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
int main(void){
    
    ll N[3],K;
    cin >> N[0] >> N[1] >> N[2] >> K;
    sort(N,N+3);
    for(ll i = 0; i < K; i++) {
        N[2] *= 2;
    }
    cout << N[0]+N[1]+N[2] << endl;
    return 0;
}


Measured memory_bytes: 256
A=list(input())
B=list(input())
C=list(input())

s=A.pop(0)
while True:
  if s=='a':
    if len(A)==0:
      print("A")
      break
    s=A.pop(0)
  elif s=='b':
    if len(B)==0:
      print("B")
      break
    s=B.pop(0)
  elif s=='c':
    if len(C)==0:
      print("C")
      break
    s=C.pop(0)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
M = 1000
S = 0

for n in range(N-1):
  if A[n]<A[n+1]:
    M+=S*A[n]
    S=0
    S+=M//A[n]
    M-=S*A[n]
  elif A[n+1]<A[n]:
    M+=S*A[n]
    S=0

if S!=0:
  M+=S*A[-1]

print(M)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v[n];
  rep(i,0,m){
    int a,b;
    cin>>a>>b;
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
  }
  bool p=false;
  rep(i,0,v[0].size()){
    int q=v[0][i];
    rep(j,0,v[q].size()){
      int r=v[q][j];
      if(r==n-1) p=true;
    }
  }
  if(p) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

LL a[N], b[N];
LL sa[N], sb[N];
int n, m, k;

int func(LL v)
{
    // if (v < sb[1]) return 0;
    // if (v >= sb[m]) return m;

    // int lo = 1, hi = m;
    // while (lo + 1 < hi)
    //{
    // int mid = (lo + hi) / 2;
    // if (v >= sb[mid])
    // lo = mid;
    // else
    // hi = mid;
    //}

    // if (v >= sb[hi]) return hi;
    // return lo;

    int ans = upper_bound(sb, sb + m + 1, v) - sb - 1;
    return ans;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (~scanf("%d%d%d", &n, &m, &k))
    {
        for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
        for (int i = 1; i <= m; i++) scanf("%d", &b[i]);

        sa[0] = 0;
        for (int i = 1; i <= n; i++) sa[i] = sa[i - 1] + a[i];
        sb[0] = 0;
        for (int i = 1; i <= m; i++) sb[i] = sb[i - 1] + b[i];

        int ans = 0;
        for (int i = 0; i <= n; i++)
        {
            if (sa[i] > k) break;

            LL left = k - sa[i];
            int idx = func(left);
            // debug(i, idx);

            ans = max(ans, i + idx);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 9888
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines()
    def loop(it: Iterator[String]): Stream[Table] = {
      readTable(it) match {
        case None => Stream.empty
        case Some((table, it2)) => table #:: loop(it2)
      }
    }
    loop(lines).foreach(printTable)
  }

  case class Table(rows: Seq[Seq[Int]])

  def printTable(table: Table): Unit = {
    val totalRow =
      for (i <- 0 until table.rows.head.length) yield {
        table.rows.map(_.apply(i)).sum
      }
    (table.rows :+ totalRow).foreach{ row =>
      (row :+ row.sum).foreach{ c => print(f"${c}%5d") }
      println()
    }
  }

  def readTable(lines: Iterator[String]): Option[(Table, Iterator[String])] = {
    val n = lines.next().toInt
    if (n <= 0)
      None
    else {
      val (it1, it2) = lines.duplicate
      val table = Table(it1.take(n).map(_.split(" ").map(_.toInt).toSeq).toSeq)
      val rest = it2.drop(n)
      Some((table, rest))
    }
  }
}



Measured memory_bytes: 48484
K, A, B = map(int, input().split())
ans = 1
ans += min(K, A-1)
K -= min(K, A-1)
if K == 0:
    print(ans)
elif B-A > 2:
    if K % 2 == 0:
        print(ans + (B-A) * K // 2)
    else:
        print(ans + (B-A) * (K-1) // 2 + 1)
else:
    print(ans+K)


Measured memory_bytes: 61784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input1 = sc.nextInt();
		int input2 = sc.nextInt();
		if (input1 % 2 == 1 && input2 % 2 == 1) {
			System.out.print("Yes");
			return;
		}
		System.out.print("No");
	}

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 5e5 + 123;
const ll mod = 1e9 + 7;

int n, m;
vector<int> g[N];
int dp[N], was[N];

void dfs(int v){
	was[v] = 1;
	//cout << v << "\n";
	for(int u: g[v]){
		if(!was[u]){
			dfs(u);
	//		cout << "-\n";
		}
	}
	was[v] = 2;

	for(int u: g[v]){
		if(was[v] != 2)
			continue;
		dp[v] = max(dp[v], dp[u] + 1);
	}
}

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

	cin >> n >> m;
	for(int i = 1;i <= m;i++){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
	}	

	int res = 0;
	for(int i = 1;i <= n;i++){
		if(!was[i]){
			dfs(i);
		}
		//cerr << dp[i] << "+\n";
		res = max(res, dp[i]);
	}
	cout << res;
}

Measured memory_bytes: 19456
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pint pair<int,int>
#define pbool pair<
#define a first
#define b second

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

int main(){ 
  
  int h,w,k; cin >> h >> w >> k;
  
  vector<vector<char>> table(h,vector<char>(w));
  
  pint pos;
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> table[i][j];
      
      if(table[i][j] == 'S'){ 
        pos = {i,j};
      
      
    }
   }
  }
  
    
  queue<pint> Q; Q.push(pos); 
  
  set<pint> se;
    
  vector<vector<bool>> visited(h,vector<bool>(w,false));
    
  visited[pos.a][pos.b] = true;
    
  while(!Q.empty()){
      //ブロックを壊さずに行ける範囲を求めたい
    
      auto p = Q.front(); Q.pop(); //空のp位置までは来れたものとする
        
        if(abs(p.a-pos.a)+abs(p.b-pos.b) <= k){ 
          se.insert({p.a,p.b});
        }
      
      
      for(int k = 0; k < 4; k++){ 
      
        
        auto q = p; 
        
        q.a += dx[k]; q.b += dy[k];
        
        if(q.a < 0 || q.a >= h || q.b < 0 || q.b >= w){ continue;}
        
        if(visited[q.a][q.b] || table[q.a][q.b] != '.'){ continue;}
        //行ったことがあるか、ないし障害物がある場合には直接到達できない
        
        Q.push(q); visited[q.a][q.b] = true;
        
      } // for
      
    } // while
    
    // 開始地点から直接行ける範囲にあらかじめtrueを貼っておいた
 
  
  //ここまでOK
  
  int ans = 1e9;
  
  for(auto ne : se){ 
    
    //ここからは最寄りの場所までぶっ壊し続ける
    
    int i = ne.a; int j = ne.b;
    
    if( i == 0 || i == h-1 || j == 0 || j == w-1 ){ 
      ans = 1; //この時点でもう外に出られているため
      
      continue;
      
    }
    
    int dist = min( min(i,h-1-i), min(j,w-1-j) );
    
    
    ans = min(ans, ((dist+k-1)/k)+1 );
    
      
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n;
  cin >> n;

  print(n * 800 - (n / 15) * 200);

  return 0;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
ans=1 if d[0]<1 else 0
d.sort()
cnt=[0]*(d[-1]+1)
for i in range(n):
  cnt[d[i]]+=1
if cnt[0]!=1:ans=0
mod=998244353
for i in d[1:]:
  ans*=cnt[i-1]
  ans%=mod
print(ans)

Measured memory_bytes: 13892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,cnt=1,y;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s.at(i);
  }
  int ac=0,wa=0,tle=0,re=0;
  rep(i,n){
    if(s.at(i)=="AC"){
      ac++;
    }else if(s.at(i)=="WA"){
      wa++;
    }else if(s.at(i)=="TLE"){
      tle++;
    }else{
      re++;
    }
  }
  cout << "AC x " << ac <<endl;
  cout << "WA x " << wa <<endl;
  cout << "TLE x " << tle <<endl;
  cout << "RE x " << re <<endl;
}


Measured memory_bytes: 6420
N=input()
H=map(int, raw_input().split())

dp=[ float("inf") for i in range(N) ] 
dp[0]=0

for i in range(N-1):
	if i+2<N:dp[i+2]=min(dp[i+2], dp[i]+ abs( H[i]-H[i+2] )  )
	if i+1<N: dp[i+1]=min(dp[i+1], dp[i]+ abs( H[i]-H[i+1] )  )

print dp[N-1]

Measured memory_bytes: 42348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dis[301][301];
const int INF=0x3fffffff;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	memset(dis,0x3f,sizeof dis);
	for(int i=1,u,v,c;i<=m;i++){
		cin>>u>>v>>c;
		dis[u][v]=c;
		dis[v][u]=c;
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(dis[i][j]<=k) dis[i][j]=1;
			else dis[i][j]=INF;
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	int q;
	cin>>q;
	while(q--){
		int u,v;
		cin>>u>>v;
		if(dis[u][v]==INF) cout<<-1<<'\n';
		else cout<<dis[u][v]-1<<'\n';
	}
}

Measured memory_bytes: 896
N=int(input())
schedule=[list(map(int,input().split()))for i in range(N)]
move_time =0
dist=0
res=0
move_time = schedule[0][0]
dist= schedule[0][1]+schedule[0][2]
if move_time<dist:
	res=1
for time in range(N-1):
	move_time=schedule[time+1][0]-schedule[time][0]
	dist = abs((schedule[time+1][1]-schedule[time][1]))+abs((schedule[time+1][2]-schedule[time][2]))
	if dist>move_time:
		res=1
		break
	if schedule[time][0]%2==0 and (schedule[time][1]+schedule[time][2])%2!=0:
		res=1
	elif schedule[time][0]%2==1 and (schedule[time][1]+schedule[time][2])%2!=1:
		res=1
if res ==1:
	print('No')
else:
	print('Yes')

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

using namespace std;
typedef long long int ll;
int main()
{
  string s,t;
  cin>>s>>t;
  if(s==t) cout<<"0"<<endl;
  else
  {
      int cnt=0;
      for(int i=0;i<s.length();i++)
      {
          if(s[i]!=t[i]) cnt++;
      }
      cout<<cnt<<endl;
  }


   return 0;
}


Measured memory_bytes: 3920
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

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

    cout << ((max({ a,b,c,d,e }) - min({ a,b,c,d,e }) <= k) ? "Yay!" : ":(") << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll modinv(ll a){
  ll b = mod,u = 1,v = 0,t;
  while(b){
    t = a/b;
    a -= t*b;swap(a,b);
    u -= t*v;swap(u,v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}
int main(){
  ll N,K,i;scanf("%lld%lld",&N,&K);
  //comb(K-1,i)*comb(N-K+1,i+1)
  ll E[2001];E[0] = E[1] = 1;
  for(i=2;i<=2000;i++) E[i] = E[i-1]*i%mod;
  for(i=0;i<K;i++){
    if(N-K < i) printf("0\n");
    else printf("%lld\n",E[K-1]*modinv(E[i])%mod*modinv(E[K-1-i])%mod*E[N-K+1]%mod*modinv(E[i+1])%mod*modinv(E[N-K-i])%mod);
  }
}

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

using namespace std;

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

  int n,k; cin>>n>>k;
  vector<int> P(n);
  int max_e = 0;
  int cur_e = 0;
  for (int i = 0; i < n; i++) {
    cin>>P[i];
    cur_e += 1+P[i];
    max_e = max(max_e, cur_e);
    if (i >= k-1)
      cur_e -= 1+P[i-k+1];
  }
  cout << fixed << (double)max_e/2 << endl;

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
/*
// AUTHOR wiley_codechef
// TASK : Atcoder
//--------------------------------HEADERS-------------------------------------------------------------//
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <limits>
#include <string>
#include <cassert>
#include <cstring> 
#include <unordered_set>
#include <unordered_map>
using namespace std; 
*/
int n, ans;
vector<int> v(200010);
unordered_map<int, int> M;
int main(){
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> v[i + 1];
		M[v[i + 1]]++;
	}
	for (int i = 1; i <= n; i++) {
		int flag = 1;
		for (ll j = 1; j * j <= v[i]; j++) {
			if (v[i] % j == 0) {
				//v[i]/j, j
				if (j == v[i] && M[j] >= 2 || j != v[i] && M[j] >= 1 || v[i]/j == v[i] && M[v[i]/j] >= 2 || v[i]/j != v[i] && M[v[i]/j] >= 1) {
					flag = 0;
					break;
				}
			}
		}
		if (flag) ans++;
	}
	cout << ans;}

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


Measured memory_bytes: 3112