akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
    int n, sum = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]), sum ^= a[i];
    for(int i=1;i<=n;i++) printf("%d ", sum^a[i]);
}

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

int main(){
	string str;
	for(int i = 1; i < 10; ++i)
	{
		for(int j = 1; j < 10; ++j)
		{
			cout << i << 'x' << j << "=" << i * j << endl;
		}
	}
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

typedef tuple<int,int,int,int> state;


string board[19];
int stone[19][15];

int num=0;

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

int bfs(){
	int wx=-1,wy=-1;
	rep(i,19)rep(j,15) stone[i][j]=-1;
	rep(i,19)rep(j,15){
		if(board[i][j]=='X')
			stone[i][j]=num++;
		if(board[i][j]=='O')
			wx=i,wy=j;
	}
	state init(0,wx,wy,(1<<20)-1);
	queue<state> q;
	q.push(init);
	while(!q.empty()){
		state cur=q.front();q.pop();
		int cost,cx,cy,mask;
		tie(cost,cx,cy,mask)=cur;
		if(cx>=19||(cx==18&&0<=cy&&cy<15))
			return cost;
		if(cx<0||19<=cx||cy<0||15<=cy) continue;
		rep(i,8){
			int nx=cx,ny=cy,nmask=mask;
			while(0<=nx+dx[i]&&nx+dx[i]<19&&0<=ny+dy[i]&&ny+dy[i]<15){
				int index=stone[nx+dx[i]][ny+dy[i]];
				if(index!=-1&&(nmask&(1<<index))){
					nmask&=(~(1<<index));
					nx+=dx[i],ny+=dy[i];
				}else
					break;
			}
			if(nx==cx&&ny==cy) continue;
			state nexts(cost+1,nx+dx[i],ny+dy[i],nmask);
			q.push(nexts);
		}
	}
	return -1;
}


int main(void){
	rep(i,19) cin >> board[i];
	cout << bfs() << endl;
	return 0;
}

Measured memory_bytes: 21584
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;
typedef complex<double> PP;
double toRad(double agl){return agl*M_PI/180.0;}
double D(P a,P b) {return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));}
PP rotate(PP a, double r){return PP(a.real()*cos(r)-a.imag()*sin(r),a.real()*sin(r)+a.imag()*cos(r));}

bool solve(P a,P c,P b,double d) {
  double r=atan2(a.S-b.S,a.F-b.F);
  PP a2=rotate(PP(c.S,0),toRad(c.F-d/2)),a3=rotate(PP(c.S,0),toRad(c.F+d/2));
  double rl=atan2(a2.imag(),a2.real()),rr=atan2(a3.imag(),a3.real());
  if(rr<rl) rr+=2*M_PI;
  if(D(a,b)<=c.S&&(rl<=r&&r<=rr||rl<=r+M_PI*2&&r+M_PI*2<=rr)) return 1;
  return 0;
}

int main() {
  int n,n2;
  while(cin >> n >> n2 && n) {
    P a[n];
    for(int i=0; i<n; i++) cin >> a[i].F >> a[i].S;
    int U,M,S,du,dm,ds;
    cin >> U >> M >> S >> du >> dm >> ds;
    P u[U],m[M],s[S];
    for(int i=0; i<U; i++) cin >> u[i].F >> u[i].S;
    for(int i=0; i<M; i++) cin >> m[i].F >> m[i].S;
    for(int i=0; i<S; i++) cin >> s[i].F >> s[i].S;
    P b[n2];
    for(int i=0; i<n2; i++) cin >> b[i].F >> b[i].S;
    int z=1;
    vector<int> ans;
    for(int i=0; i<n; i++) {
      int cnt=0;
      for(int j=0; j<n2; j++) {
        bool f=solve(a[i],b[j],P(0,0),du);
        for(int k=0; k<U; k++) {
          if(solve(a[i],b[j],u[k],du)) f=0;
        }
        for(int k=0; k<M; k++) {
          if(solve(a[i],b[j],m[k],dm)) f=0;
        }
        for(int k=0; k<S; k++) {
          if(solve(a[i],b[j],s[k],ds)) f=0;
        }
        cnt+=f;
      }
      if(cnt>z) {
        z=cnt;
        ans.clear();
        ans.push_back(i+1);
      } else if(cnt==z) ans.push_back(i+1);
    }
    if(!ans.size()) cout << "NA" << endl;
    else {
      for(int i=0; i<ans.size(); i++) {
        if(i) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
int main(void){
    int N,i,ac=0,wa=0,tle=0,re=0;
    char S[100001][5];
    
    scanf("%d",&N);
    for(i=1;i<=N;i++){
        scanf("%s",S[i]);
    }
    
    for(i=1;i<=N;i++){
        if(strcmp(S[i],"AC")==0){
            ac++;
        }else if(strcmp(S[i],"WA")==0){
            wa++;
        }else if(strcmp(S[i],"TLE")==0){
            tle++;
        }else if(strcmp(S[i],"RE")==0){
            re++;
        }
    }
    
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
    
    return 0;
}

Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100005

int main(){
    int n; cin >> n;
    ll c[MAX];
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(c, c+n);
    if(n%2 != 0){
        if(c[0] != 0){
            
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i = 0; i < n/2; i++){
        bool f = true;
        if(n%2 != 0){
            int j = i+1;
            if(c[2*j-1] != c[2*j] || c[2*j-1] %2 != 0 || c[2*j] %2 != 0) f = false;
        }else{
            if(c[2*i+1] != c[2*i] || c[2*i+1] %2 == 0 || c[2*i] %2 == 0) f = false;
        }

        if(!f){
            cout << 0 << endl;
            return 0;
        }
        ans = ans*2%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const lines = input.split('\n')
    const [N, M] = lines[0].split(' ').map(Number)

    const C = []
    for (let i = 0; i < M; i++) {
    C[i] = [...lines[i + 1].split(' ').map(Number), i]
    }

    C.sort((a, b) => {
        if (a[0] === b[0]) {
            return a[1] > b[1] ? 1 : -1
        } else {
            return a[0] > b[0] ? 1 : -1
        }
    })

    let ans = []
    let p = 0
    let x = 0
    for (let i = 0; i < M; i++) {
        if (p === C[i][0]) {
            x ++
        } else {
            p = C[i][0]
            x = 1
        }
        ans.push([
            ( '000000' + C[i][0] ).slice( -6 ) +
            ( '000000' + x ).slice( -6 ),
            C[i][2]
        ])
    }

    ans.sort((a, b) => {
        return a[1] > b[1] ? 1 : -1
    })

    for (let i = 0; i < M; i++) {
        ans[i] = ans[i][0]
    }

    console.log(ans.join('\n'))

})(input)


Measured memory_bytes: 108496
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  map<int,vector<int>> mp;
  for(int i=0; i<N; i++){
    mp[A[i]].emplace_back(i);
  }
  vector<vector<ll>> dp(60,vector<ll>(N,0));
  for(auto m: mp){
    vector<int> pos = m.second;
    pos.emplace_back(pos[0] + N);
    for(int i=1; i<pos.size(); i++){
      dp[1][pos[i-1]] = (pos[i] - pos[i-1]+1);
    }
  }
  for(int i=2; i<60; i++){
    for(int j=0; j<N; j++){
      dp[i][j] = min(INF,dp[i-1][j] + dp[i-1][(j+dp[i-1][j])%N]);
    }
  }
  // for(int i=1; i<20; i++){
  //   for(int j=0; j<N; j++){
  //     cout << dp[i][j] << " \n"[j+1==N];
  //   }
  // }
  ll now = N*K;
  ll pos = 0;
  for(int i=59; i>=1; i--){
    if(now >= dp[i][pos]){
      now -= dp[i][pos];
      pos = (pos + dp[i][pos])%N;
    }
  }
  if(now == 0){
    return 0;
  }
  set<int> used;
  stack<int> st;
  // cout << now << "\n";
  // cout << pos << "\n";
  while(now){
    if(used.count(A[pos])){
      while(used.count(A[pos])){
        used.erase(st.top());
        st.pop();
      }
    }else{
      st.emplace(A[pos]);
      used.emplace(A[pos]);
    }
    pos++;
    pos %= N;
    now--;
  }
  vector<int> ans;
  while(st.size()){
    ans.emplace_back(st.top());
    st.pop();
  }
  reverse(ans.begin(),ans.end());
  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << " \n"[i+1 == ans.size()];
  }
  return 0;
}

Measured memory_bytes: 131572
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second


main(){
  int b,r,g,c,s,t;
  while(cin>>b>>r>>g>>c>>s>>t,b|r|g|c|s|t){
    cout<<100+2*c+13*(5*b+3*r)+g*7-3*(t-s-5*b-3*r)+15*(b+r)<<endl;
  }
}

Measured memory_bytes: 0
def main():
    N, K = map(int, input().split())
    S = input()
    # １で始まるグループでK=1を想定する
    # [1，0，1]だとすると、K=1で2K+1で1グループは表せる
    c_num = "1"  # 必ず1でスタートする形とする。0で始まれば、0個の1を頭に入れる
    cnt = 0
    seq = []

    for i in S:
        if i == c_num:
            cnt += 1
        else:
            c_num = i
            seq.append(cnt)
            cnt = 1
    seq.append(cnt)
    # print(seq)
    # print(leng_seq)
    if len(seq) % 2 == 0:  # "1"から始まる順番で、配列が偶数ということは0で終わってる=>ケツに0個の1をブチコム
        seq.append(0)
    # 全部１になるケース
    if len(seq) <= 2*K+1:  # 当該の要素含め前後消えるから2K+1
        print(sum(seq))
        return

    answer = 0
    total = 0
    stpr = 0

    for j in range(len(seq)-2*K):
        while stpr < j+2*K+1:
            total += seq[stpr]
            stpr += 1
        if j % 2 == 0:  # 1からスタートするものだけ2k+1分を抽出
            answer = max(answer, total)
        total -= seq[j]

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45552
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])


Measured memory_bytes: 20388
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, M, dp[MAXN], pg[MAXN];
vector <int> v[MAXN];
void dfs(ll x, ll p)
{
	dp[x] = 1;
	for(auto i : v[x])
	{
		if(i==p) continue;
		dfs(i,x);
		dp[x] *= (dp[i]+1);
		dp[x] %= M;
	}
	// dp[x] *= (pg[x]+1);
	
}
void ans(ll x, ll p)
{
	vector <ll> sumf,sumb;
	for(auto i : v[x])
	{
		if(i==p) { if(sumf.size()) sumf.pb((sumf.back()*(pg[x]+1))%M); else sumf.pb((pg[x]+1)%M); continue; }
		if(sumf.empty()) sumf.pb((dp[i]+1)%M);
		else sumf.pb((sumf.back()*(dp[i]+1))%M);
	}
	reverse(all(v[x]));
	for(auto i : v[x])
	{
		if(i==p) { if(sumb.size()) sumb.pb((sumb.back()*(pg[x]+1))%M); else sumb.pb((pg[x]+1)%M); continue; }
		if(sumb.empty()) sumb.pb((dp[i]+1)%M);
		else sumb.pb((sumb.back()*(dp[i]+1))%M);
	}
		// cout << "\n\n\n";
		// for(auto i : sumf) cout << i << " "; cout << "\n";
		// for(auto i : sumb) cout << i << " "; cout << "\n";
		// cout << "\n\n\n";
	reverse(all(sumb));
	reverse(all(v[x]));
	for(ll i = 0; i < v[x].size(); i++)
	{
		if(v[x][i]==p) continue;
		pg[v[x][i]] = ((i-1 >= 0 ? sumf[i-1] : 1) * (i+1 < sumb.size() ? sumb[i+1] : 1))%M;
	}
	for(auto i : v[x])
	{
		if(i==p) continue;
		ans(i,x);
	}
	return;
}
int main()
{
	FAST
	cin >> n >> M;
	FOR(i,1,n)
	{
		ll a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	// pg[1] = 1;
	dfs(1,1);
	ans(1,1);
	FOR(i,1,n+1) cout << (dp[i]*(pg[i]+1))%M << '\n'; 
}


Measured memory_bytes: 29568
#include <bits/stdc++.h>
using namespace std;
int n, a[105];
int main() {
    scanf("%d", &n);
    double s = 0;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]), s += a[i];
    s /= n;
    int ans = 0;
    for (int i = 1; i < n; i++)
        if (fabs(a[ans]-s) > fabs(a[i]-s)) ans = i;
    printf("%d\n", ans);
}


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

using namespace std;
using ll = long long;

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

    const int kmax = 40;

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    if(k > kmax) {
        for(int i = 0; i < n; ++i) {
            printf("%d", n);
            i != n - 1 ? printf(" ") : printf("\n");
        }
        return 0;
    }

    vector<int> b(n);
    int l, r;

    for(int j = 0; j < k; ++j) {
        b = vector<int>(n, 0);
        for(int i = 0; i < n; ++i) {
            l = max(0, i - a.at(i));
            r = min(n - 1, i + a.at(i));
            b.at(l)++;
            if(r + 1 < n) b.at(r + 1)--;
        }

        a.at(0) = b.at(0);
        for(int i = 1; i < n; ++i) {
            b.at(i) += b.at(i - 1);
            a.at(i) = b.at(i);
        }
    }

    for(int i = 0; i < n; ++i) {
        printf("%d", a.at(i));
        i != n - 1 ? printf(" ") : printf("\n");
    }

    return 0;
}

Measured memory_bytes: 5516
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

// [0, x]
long long cumxor(long long x){
    if (x <= 0) return 0;
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x + 1;
    return 0;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (cumxor(b) ^ cumxor(a - 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
let NM = readLine()!.split(separator: " ").map { Int($0)! }
let N = NM[0], M = NM[1]
let A = readLine()!.split(separator: " ").map { Int($0)! }
let sum = A.reduce(0) { $0 + $1 }
if N - sum < 0 {
  print(-1)
} else {
  print(N - sum)
}

Measured memory_bytes: 8464
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == b && b == c)
        printf("1");
    else if (a == b || b == c || c == a)
        printf("2");
    else
        printf("3");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MOD1 = 131;
const int MOD2 = 149;
struct RollingHash {
    vector<long long> H1, H2, M1, M2;
    RollingHash(const string &s) {
        H1.resize(s.size() + 1);
        H2.resize(s.size() + 1);
        M1.resize(s.size());
        M2.resize(s.size());
        M1[0] = M2[0] = 1;
        for (int i = 1; i < s.size(); i++) {
            M1[i] = M1[i - 1] * MOD1 % MOD;
            M2[i] = M2[i - 1] * MOD2 % MOD;
        }
        for (int i = 0; i < s.size(); i++) {
            H1[i + 1] = (H1[i] * MOD1 + s[i]) % MOD;
            H2[i + 1] = (H2[i] * MOD2 + s[i]) % MOD;
        }
    }
    long long hash(int L, int R) {
        int h1 = (H1[R] + MOD - H1[L] * M1[R - L] % MOD) % MOD;
        int h2 = (H2[R] + MOD - H2[L] * M2[R - L] % MOD) % MOD;
        return (long long)h1 << 32 | h2;
    }
};
int main() {
    int N; cin >> N;
    string S; cin >> S;
    RollingHash H(S);
    int ok = 0, ng = N + 1;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool found = false;
        for (int i = 0; i <= N - mid; i++) {
            for (int j = i + mid; j <= N - mid; j++) {
                if (H.hash(i, i + mid) == H.hash(j, j + mid)) {
                    found = true;
                    goto FOUND;
                }
            }
        }
        FOUND:;
        (found ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>numbers;
ll dp[100005];
vector<vector<ll>>graph;
ll solve(ll node) {
	if (graph[node].size() == 0) { return dp[node] = 0; }
	if (dp[node] != -1) { return dp[node]; }
	else {
		ll m = 0;
		for (int i = 0; i < graph[node].size(); ++i) {
			m = max(m, 1 + solve(graph[node][i]));
		}
		return dp[node] = m;
	}
}
int main() {
	ll n, m;
	cin >> n >> m;
	graph.resize(n + 1);
	for (int i = 0; i < m; ++i) {
		ll u, v;
		cin >> u >> v;
		graph[u].push_back(v);
	}
	memset(dp, -1, sizeof(dp));
	ll maxi = -1;
	for (int i = 1; i <= n; ++i) {
		maxi = max(maxi, solve(i));
	}
	cout << maxi << "\n";
	
	return 0;
}

Measured memory_bytes: 8576
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 2e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

void solve(){
	ll a[3];
	rep(i,0,3)
		cin >>a[i];
	sort(a,a+3);
	cout << a[1]-a[0]+(a[2]-a[1]);
}

int main() {
	isc;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;


int main(){
  int n,m,p;
  while(true){
    cin >> n >> m;
    if(n+m == 0)break;
    vector<int> vec;
    for(int i=0;i<n;i++){
      cin >> p;
      vec.push_back(p);
    }
    sort(vec.begin(),vec.end(),greater<int>() );
    int sum = 0,cnt=1;
    for(int i=0;i<vec.size();i++){
      if(cnt%m == 0){
	cnt = 1;
	continue;
      }
      sum+=vec[i];
      cnt++;

    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
n=int(input())
a=list(map(int,input().split()))
pos,zero,neg=0,0,0
maxi=-10**10
mini=10**10
for num in a:
    if num>0:
        pos+=1
    elif num==0:
        zero+=1
    else:
        neg+=1
    maxi=max(maxi,num)
    mini=min(mini,num)
maxidx=a.index(maxi)
minidx=a.index(mini)
if neg==0:
    print(n-1)
    for i in range(1,n):
        print(i,i+1)
elif pos==0:
    print(n-1)
    for i in reversed(range(1,n)):
        print(i+1,i)
else:
    print(2*n-2)
    if abs(maxi)>=abs(mini):
        for i in range(n):
            if i!=maxidx:
                print(maxidx+1,i+1)
        for i in range(1,n):
            print(i,i+1)
    else:
        for i in range(n):
            if i!=minidx:
                print(minidx+1,i+1)
        for i in reversed(range(1,n)):
            print(i+1,i)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include<math.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define MOD 1000000007LL
#define ROD 1000000000
#define INF 12345678
#define MIN(a,b) (a>b?b:a)
using namespace std;
#include<bits/stdc++.h>
#include<math.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define ll long long
#define mp make_pair
#define  piii pair<pair<ll,ll>,pair <ll,ll>>
#define pii pair <ll,ll>
#define fi first
#define se second
ll ch(ll);
ll n,cr[100005],tot,x;
piii br[100005];
int main()
{
	cin>>n>>x;
	rep(i,0,n)
	{
		cin>>br[i].fi.se>>br[i].se.fi>>br[i].se.se;
		br[i].fi.fi=(br[i].se.se)*(x-br[i].fi.se)+br[i].fi.se*br[i].se.fi;
		tot+=br[i].fi.se*br[i].se.fi;
	}
	//cout<<tot<<"\n";
	sort(br,br+n,greater <piii> ());
	rep(i,0,n)
	{
		cr[i]=br[i].fi.fi;
		if(i-1>=0)
		cr[i]+=cr[i-1];
	}
	cr[n]=cr[n-1];
	// rep(i,0,n+1)
	// cout<<cr[i]<<" ";
	// rep(i,0,n)
	// cout<<br[i].fi.se<<" "<<br[i].se.fi<<" "<<br[i].se.se<<" "<<cr[i]<<"\n";
	ch(2497);
	ll low=0,high=n*x,mid,ans;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(ch(mid))
		{
			ans=mid;
			high=mid-1;
		}
		else
			low=mid+1;
	}
	//cout<<ch(400)<<" ";
	cout<<ans;
}
ll ch(ll mid)
{
	ll q=mid/x,r=mid-x*q;
	if(mid==n*x)
		return 1;
	//cout<<r<<" ";
	rep(i,0,n)
	{
		ll temp=0;
		if(i<q)
		{
			if(q>=0)
			temp+=cr[q]-br[i].fi.fi;
			//temp+=(r>br[i].fi.se?r*br[i].se.se:r*br[i].se.fi);
			temp+=(r>br[i].fi.se?(r-br[i].fi.se)*br[i].se.se+br[i].fi.se*br[i].se.fi:r*br[i].se.fi);		
		}
		else
		{
			if(q-1>=0)
			temp+=cr[q-1];
			temp+=(r>br[i].fi.se?(r-br[i].fi.se)*br[i].se.se+br[i].fi.se*br[i].se.fi:r*br[i].se.fi);		
			//cout<<"HERE"<<br[i].fi.se<<" "<<r<<" "<<r-br[i].fi.se<<" "<<br[i].se.se<<" ";
		}
		// ll qw=r>br[i].fi.se?(r-br[i].fi.se)*br[i].se.se+br[i].fi.se*br[i].se.fi:r*br[i].se.fi;
		// cout<<mid<<" "<<tot<<" "<<qw<<" "<<r<<" "<<" "<<temp<<"\n";
		if(temp>=tot)
			return 1;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& w : a) cin >> w;
  int n4 = 0, n2 = 0, n0;
  for (auto&& w : a) {
    if (w % 2 == 0) n2++;
    if (w % 4 == 0) n4++;
  }
  n0 = n - n2;
  // cerr << n0 << ' ' << n2 << ' ' << n4 << endl;

  if (n4 >= n0 || (n4 == n0 - 1 && n2 == n4))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<string.h>
#include<math.h>
#include<unordered_map>
#include <deque>
using namespace std;


struct T {
	int t[3];
};

std::deque<T> que;

int ij[4][2] = {{1, 0},{-1, 0},{0, 1},{0, -1}};

int s[50][50] = {};
int h, w, c=0;
int mi = 1000;



int main()
{
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char ct;
			cin >> ct;
			if (ct == '.')c++;
			s[i][j]= ct=='.' ? 1000 : 2000;
		}
	}

	s[0][0] = 0;
	T f = { {0,0,0} };

	que.push_back(f);

	while (!que.empty()) {

		T t = que.front();
		que.pop_front();

		int ni=t.t[0], nj=t.t[1], num=t.t[2];


		if (ni == h - 1 && nj == w - 1) {
			mi = min(mi, num);
		}

		for (int i = 0; i < 4; i++) {
			int it = ni + ij[i][0];
			int jt = nj + ij[i][1];

			if (it>=0 && it < h && jt>=0 && jt < w 
				&& s[it][jt] != 2000) {

				T tt;
				tt.t[0]=it;
				tt.t[1]=jt;
				tt.t[2]=num+1;

				if (s[it][jt] > num + 1) {
					s[it][jt] = num + 1;
					que.push_back(tt);
				}
			}
		}
	}


	if (mi == 1000) mi = -1;
	else mi = c - 1 - mi;

	cout << mi << endl;

/*	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] != 1000 && s[i][j] != 2000)cout << s[i][j] << " ";
			else cout << (s[i][j]==1000 ? "." : "#") << " ";
		}
		cout << endl;
	}*/

	return 0;
}


Measured memory_bytes: 256
class Combinations:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod # mod must be prime
        self.prepare()

    def prepare(self):
        self.factorialNumInverse = [None] * (n + 1)
        self.naturalNumInverse = [None] * (n + 1)
        self.fact = [None] * (n + 1)
        self.inverseOfNumber()
        self.inverseOfFactorial()
        self.factorial()

    def inverseOfNumber(self):
        self.naturalNumInverse[0] = self.naturalNumInverse[1] = 1
        for i in range(2, n + 1):
            self.naturalNumInverse[i] = (self.naturalNumInverse[self.mod % i] * (self.mod - self.mod // i) % self.mod)

    def inverseOfFactorial(self):
        self.factorialNumInverse[0] = self.factorialNumInverse[1] = 1
        for i in range(2, n + 1):
            self.factorialNumInverse[i] = (self.naturalNumInverse[i] * self.factorialNumInverse[i - 1]) % self.mod

    def factorial(self):
        self.fact[0] = 1
        for i in range(1, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % self.mod

    def nCk(self, n, k):
        ans = ((self.fact[n] * self.factorialNumInverse[k]) % self.mod * self.factorialNumInverse[n - k]) % self.mod
        return ans

MOD = 10 ** 9 + 7

n, k = map(int, input().split())
a = sorted(map(int, input().split()))

combs = Combinations(n, MOD)

def calcSum(a):
    ret = 0
    for i in range(k - 1, n):
        ret += (combs.nCk(i, k - 1) * a[i]) % MOD
        ret %= MOD
    return ret

print((calcSum(a) - calcSum(a[::-1])) % MOD)

Measured memory_bytes: 19800
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String N = sc.next();
		
		if(N.equals("Sunny")) {
			System.out.println("Cloudy");
		}
		if(N.equals("Cloudy")) {
			System.out.println("Rainy");
		}
		if(N.equals("Rainy")) {
			System.out.println("Sunny");
		}

   		sc.close();
        return ;

    }
    
}


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

int main(){
    int A[3][3];
    bool AB[3][3];
    fill(AB[0],AB[3],false);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> A[j][i];
        }
    }
    int N;
    cin >> N;
    int b[N];
    for(int i=0;i<N;i++){
        cin>>b[i];
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(b[i]==A[k][j]){
                    AB[k][j]=true;
                }
            }
        }
    }
    //  yoko
    for(int i=0;i<3;i++){
        int count=0;
        for(int j=0;j<3;j++){
            if(AB[j][i]){
                count++;
            }
        }
        if(count==3){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    //tate
    for(int i=0;i<3;i++){
        int count=0;
        for(int j=0;j<3;j++){
            if(AB[i][j]){
                count++;
            }
        }
        if(count==3){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    //naname
    int count=0;
    for(int i=0;i<3;i++){
        if(AB[i][i]){
            count++;
        }
        if(count==3){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
     count=0;
    for(int i=0;i<3;i++){
        
        if(AB[2-i][i]){
            count++;
        }
        if(count==3){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No"<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc109_c
{
    class Program
    {
        static int gcd(int a, int b)
        {
            if (b == 0)
            {
                return a;
            }
            else
            {
                return gcd(b, a % b);
            }
        }

        static void Main(string[] args)
        {
            string[] nums = Console.ReadLine().Split(' ');
            int n = int.Parse(nums[0]);
            int x = int.Parse(nums[1]);

            nums = Console.ReadLine().Split(' ');
            int[] xs = new int[n];

            for(int i = 0; i < n; ++i)
            {
                xs[i] = int.Parse(nums[i]) - x;

                if(xs[i] < 0)
                {
                    xs[i] *= -1;
                }
            }

            int d = xs[0];
            for (int i = 1; i < n; ++i)
            {
                d = gcd(d, xs[i]);
            }

            Console.WriteLine(d);
        }
    }
}


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

using namespace std;

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

    long long a, b, x;
    cin >> a >> b >> x;
    long long f = (a + x - 1) / x * x;
    long long l = b / x * x;
    cout << (l - f) / x + 1;

    return 0;
}


Measured memory_bytes: 256
x = int(input())

for i in range(-4000,4000) :
    flag = 0
    for j in range(-4000,i) :
        if x%(i-j) != 0 :
            continue
        v = x//(i-j)
        c = i**4+j**4+i*j*(i**2+i*j+j**2)
        if v == c :
            print(i,j)
            flag = 1
            break
    if flag == 1 :
        break

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */

struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<ll> edges_cost; // edge cost

	//for dijkstra
	int done; //conform or not
	ll cost; // now cost
	int from;

	bool operator<(const Vertex& another) const { // priority --> min
		return another.cost < cost; // order(cost)
	}

	bool operator==(const Vertex& another) const {
		return another.cost == cost; // order(cost)
	}
};

int main() {
	int N;
	cin >> N;
	static Vertex V[100002];
	REP(i,N-1){
	    int u,v,w;
	    cin >> u >> v >> w;
	    V[u].edges_to.PB(v);
	    V[u].edges_cost.PB(w);
		V[v].edges_to.PB(u);
		V[v].edges_cost.PB(w);
	}

	queue<int> Q;
	Q.push(1);
	V[1].done = 1;

	while(!Q.empty()){
		int now = Q.front();
		Q.pop();
		REP(i,V[now].edges_to.size()){
			int next = V[now].edges_to[i];
			if (V[next].done != 0) continue;
		    int nextcost = V[now].edges_cost[i] % 2;
		    if (nextcost == 0){
		    	V[next].done = V[now].done;
		    }else{
		    	V[next].done = (V[now].done + 1) % 2 + 2;
		    }
		    Q.push(next);
		}
	}

	FORq(i,1,N){
		cout << (V[i].done - 1) % 2  << "\n";
	}

}

Measured memory_bytes: 14336
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

ll H, N, s;

int main() {
    cin >> H >> N;
    for(int i=0; i<N; i++){
        ll t;
        cin >> t;
        s += t;
    }
    if(s>=H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

ans = 0
1.upto(h.max) do |i|
  ans += 1
  f_flag = false
  flag = false
  n.times do |t|
    if h[t] >= i
      if flag
        ans += 1
      end
      f_flag = true
      flag = false
    else
      if f_flag
        flag = true
      end
    end
  end
end
p ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll u[N],m[N],b[N];
vector<vector<int> > adj;
bool visited[N][10]={};
int nodesNum;
int s,t;
int bfs(int node)
{
   queue<pair<int,int> > q;
   q.push({node,0});
   visited[node][0] = 1;
   while (!q.empty())
   {
       node = q.front().first;
       int dist=q.front().second;
       if(node==t&&(dist)%3==0)return dist/3;
       q.pop();
       for (int i=0;i< adj[node].size();i++){
            int child=adj[node][i];
         if (!visited[child][(dist+1)%3])
           {
               q.push({child,dist+1});
               visited[child][(dist+1)%3] = 1;
           }
       }

   }
   return -1;

}

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

int n,m;
cin>>n>>m;
adj.resize(n+5);
for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v;
    adj[u].push_back(v);
}

cin>>s>>t;
cout<<bfs(s);

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    if (s[2] == s[3]) {
        if (s[4] == s[5]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int s;
  cin >>s;
  int N=1000000;
  int a[1000000];
  a[1]=s;
  for(int i=2;i<=N;i++){
    if(a[i-1]%2==0) a[i]=a[i-1]/2;
    else a[i]=3*a[i-1]+1;
    for(int j=1; j<i ;j++){
      if(a[i]==a[j])
      {cout << i<<endl; return 0;}
    }
  }


}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b;cin>>a>>b;
  cout << (a*3+b)/2 << endl;
}


Measured memory_bytes: 256
import sys; input = sys.stdin.readline
mod = int(1e9)+7
n = int(input())
lis = list(map(int, input().split()))
pre = [0]*n
pre[0] = lis[0]
for i in range(1, n): pre[i] = pre[i-1] + lis[i]
ans = 0
for i in range(1, n): ans = (ans + (lis[i-1]*(pre[n-1] - pre[i-1]))%mod)%mod
print(ans)

Measured memory_bytes: 105368
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	string a, b, c; cin >> a >> b >> c;
	if( a.back() == b.front() && b.back() == c.front() ) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool occ[26];

int main() {
	string s;
	cin>>s;
	for (int i=0; i<s.length(); i++) occ[s[i]-'a']=true;
	bool found=false;
	for (int i=s.length()-1; i>=0; i--) {
		for (int j=(i==s.length()-1) ? 0 : s[i+1]-'a'+1; j<26; j++) {
			if (!occ[j]) {
				cout<<s.substr(0,i+1)<<char(j+'a')<<endl;
				found=true;
				break;
			}
		}
		if (found) break;
		occ[s[i]-'a']=false;
	}
	if (found) return 0;
	for (int j= s[0]-'a'+1; j<26; j++) {
			if (!occ[j]) {
				cout<<char(j+'a')<<endl;
				found=true;
				break;
			}
		}
	if (!found) cout<<-1<<endl;
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int const& min = A > B ? B : A;
    int temp =  (A + B) - N;
    cout << min << ' ' << ((temp > 0) ? temp : 0)  << endl;
    std::min(A, B);
    return 0;
}



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

int tot=0;
const int m=32000;
bool p[m]={0};
int prime[m]={0};

bool isprime(int n)
{
    if(n==1)
        return false;
    for(int i=1;prime[i]*prime[i]<=n;i++)
        if(n%prime[i]==0)
            return false;
    return true;
}

void intprimes()
{
    for(int i=2; i<=m; i++)
    {
        if(!p[i])
            prime[++tot]=i;
        for(int j=1;i*prime[j]<=m;j++)
        {
            p[i*prime[j]]=true;
            if(i%prime[j]==0)
                break;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    intprimes();
    int n;
    cin>>n;
    for(int i=n; i<n*3; i++)
        if(isprime(i))
        {
            cout<<i<<'\n';
            return 0;
        }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
ll c(ll n){
    return n*(n-1)/2;
}
int main() {
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    vector<int> cnt(n);
    rep(i,n){
        cnt[a[i]]++;
    }
    ll base=0;
    for(int i=0;i<n;i++){
        base+=c(cnt[i]);
    }
    for(int i=0;i<n;i++){
        ll result=base;
        result-=c(cnt[a[i]]);
        result+=c(cnt[a[i]]-1);
        cout<<result<<endl;
    }
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* constant */

#define MAX_D	(100)
#define MAX_M	(300)
#define MAX_K	(50)

/* typedef */

typedef struct _wp_t {
  int w, p;
} wp_t;

/* global variables */

static int sn, dn, m;
static int kis[MAX_D], fs[MAX_D];
static wp_t swts[MAX_D][MAX_K];
static int ws[MAX_D + 1][MAX_M + 1], dws[MAX_M + 1];

/* main */

int main(int argc, char **argv) {
  int d, dwi, f, i, j, k, max_w, min_p, pk, pu, wku;
  wp_t *swpt;

  while (scanf("%d %d %d", &sn, &dn, &m) == 3) {
    for (i = 0; i < sn; i++) {
      scanf("%d", &(kis[i]));
      for (j = 0; j < kis[i]; j++)
	scanf("%d %d", &(swts[i][j].w), &(swts[i][j].p));
    }

    for (i = 0; i < dn; i++)
      scanf("%d", &(fs[i]));

    bzero(ws, sizeof(ws));

    for (d = 0; d < dn; d++) {
      bzero(dws, sizeof(dws));

      f = fs[d];

      for (i = 0; i < kis[f]; i++) {
	swpt = &(swts[f][i]);

	for (pk = m; pk >= swpt->p; pk--) {
	  dwi = dws[pk - swpt->p] + swpt->w;
	  if (dws[pk] < dwi) dws[pk] = dwi;
	}
      }

      for (pk = 0; pk <= m; pk++) {
	for (pu = 0; pu <= pk; pu++) {
	  wku = ws[d][pk - pu] + dws[pu];
	  if (ws[d + 1][pk] < wku) ws[d + 1][pk] = wku;
	}
      }
    }

    max_w = 0;
    min_p = 0;

    for (pk = 0; pk <= m; pk++) {
      if (max_w < ws[dn][pk]) {
	max_w = ws[dn][pk];
	min_p = pk;
      }
    }

    printf("%d %d\n", max_w, min_p);
  }

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void solve(){
    string s1,s2;
    cin>>s1>>s2;
    int l1=s1.size();
    int l2=s2.size();
    int ans=INT_MAX;
    for(int i=l2-1;i<l1;i++)
    {
        string temp=s1.substr(i-l2+1,l2);
        int curr=0;
        for(int j=0;j<l2;j++)
        {
                if(temp[j]!=s2[j])
                    curr++;
        }
        ans=min(ans,curr);
    
    }
    cout<<ans<<endl;
}
int main()
{
   int t=1;
  // int t;
    //cin>>t;
    while(t--)
        solve();  
   return 0;   
}




Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int INF = 0x3f3f3f3f;

int main()
{
	int m, n;
	cin >> n;
	int ans = -INF;
	cin >> m;
	int Min = m;
	for(int i = 2; i <= n; i++)
	{
		cin >> m;
		ans = max(ans, m - Min);
		Min = min(Min, m);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3192
import math
import numpy

N, D = map(int, input().split())
P = [input().split() for i in range(N)]

A = 0

for point in P:
    X, Y = point
    if (math.sqrt(((int(X) * int(X)) + (int(Y) * int(Y))))) <= D:
        A += 1
    else:
        A += 0

print(A)

Measured memory_bytes: 85556
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  int l[n];
  for(int i=0;i<n;i++) {
    cin>>l[i];
  }
  int ans=0;
  int d[n+1];
  d[0]=0;
  for(int i=0;i<n;i++) {
    d[i+1]=d[i]+l[i];
  }
  for(int i=0;i<=n;i++) {
    if(d[i]>x){
      break;
    }
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a  = Integer.parseInt(scan.next());
    int b  = Integer.parseInt(scan.next());
    int c  = Integer.parseInt(scan.next());
    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
	}
}



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

int main(){
  float nlist[1002] = {0};
  int N,T,A;
  int ansind = 0;

  cin >>N>>T>>A;

  for(int i = 0; i<N;i++){
    int H;

    cin >>H;
    nlist[i] = T-0.006*H;
  }



  float dist = 99999999;

  for(int i = 0; i<N;i++){
    if (abs(nlist[i] - A) < dist){
      ansind = i;
      dist = abs(nlist[i] - A);
    }
  }

  cout <<ansind+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2
#define INF 99999

int A[N][N],color[N],d[N],p[N];
int n,time = 0;

void prim(){
  int i,min,u,v;
  for(i = 0; i < n; i++){
    color[i] = W;
    d[i] = INF;
    p[i] = -1;
  }
  d[0] = 0;

  while(1){
    min = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(color[i] != B && d[i] < min){
	min = d[i];
	u = i;
      }
    }
    if(u == -1) break;
    color[u] = B;

    for(v = 0; v < n; v++){
      if(color[v] != B && A[u][v] != INF){
	if(A[u][v] < d[v]){
	  d[v] = A[u][v];
	  p[v] = u;
	  color[v] = G;
	}
      }
    }
  }
}


int main(){
  int i,j,a,sum = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
       scanf("%d",&a);
         if(a == -1) A[i][j] = INF;
         else A[i][j] = a;
    }
  }
  
  prim();
  for(i = 0; i < n; i++){
    if(p[i] != INF) sum += A[i][p[i]];
  }
  printf("%d\n",sum);
 
 
  
  return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
int lub(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<=d[m]?lub(l,m,n,d):lub(m+1,r,n,d);
}
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMAX）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
long long int MIN(long long a,long long b){return a<b?a:b;}
/*long long f(long long a,long long b,long long min,long long *t){
  long long i,ans=min;
  for(i=0;i<b;i++)ans+=MIN(min+t[i],t[i]*(a+1));//,printf("%lld\n",ans);
  return ans;
  }//*/
long long f(int a,int b,long long min,int *s,int *t,long long *d){
  long long i,j;
  //for(i=0;i<a;i++)printf("%d ",t[i]);printf("\n"); 
  for(i=0;i<b;i++){
    j=lub(0,a,s[i],t);//printf("%d %lld\n",s[i],j);
    min+=d[j]+s[i]*(a+1-j);//printf("%lld %lld %lld\n",d[j],a+1-j,s[i]*(a+1-j));
  }
  return min;
}
    
int main(){
  int i,h,w,a,x[100010],y[100010];
  long long sw,sh,dx[100010],dy[100010];;
  scanf("%d %d",&w,&h);
  for(i=sw=0;i<w;i++){
    scanf("%d",&a);
    hin(a);
    sw+=a;
  }
  for(i=0;i<w;i++)x[i]=N[hout()];
  for(i=dx[0]=0;i<w;i++)dx[i+1]=dx[i]+x[i];
  R=C=1;
  for(i=sh=0;i<h;i++){
    scanf("%d",&a);
    hin(a);
    sh+=a;
  }
  for(i=0;i<h;i++)y[i]=N[hout()];
  for(i=dy[0]=0;i<h;i++)dy[i+1]=dy[i]+y[i];
  printf("%lld\n",sh<sw?f(h,w,sh,x,y,dy):f(w,h,sw,y,x,dx));
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string a,b;
int main() {
	cin>>a>>b;
	cout<<b+a;
	return 0;
}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans, tmp;
    tmp = n / (a+b);
    ans = tmp * a;
    ll tmp2 = n % (a+b);
    ans += min(a, tmp2);
    cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b % a, a)


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


# print(lcm(lcm(3,4),6))
N = int(input())
A = [int(_) for _ in input().split()]
tmp = A[0]
for a in A[1:]:
    tmp = lcm(tmp, a)
tmp-=1
ans = 0
for a in A:
    ans +=tmp % a
print(ans)


Measured memory_bytes: 3316
n, k = gets.split(" ").map(&:to_i)
ans = 0

if (n - k) < 0 
  ans = (n - k).abs > n ? n : (n - k).abs 
else   
  nn = n - k * (n / k).floor
  ans = (nn - k).abs > nn ? nn : (nn - k).abs 
end

puts ans


Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int x, y;
  cin >> x >> y;

  if(y % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  int t = (y - 2 * x) / 2;
  int c = x - t;
  if(t < 0 || c < 0) {
    cout << "No" << endl;
    return 0;
  }

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


Measured memory_bytes: 3632