akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

const int MAX = 100005;

vector<bool> eratosthenes() {
  vector<bool> is_prime(MAX, true);
  is_prime.at(0) = false; is_prime.at(1) = false;
  for (int i = 2; i < MAX; i++) {
    if (!is_prime.at(i)) continue;
    for (int j = i * 2; j < MAX; j += i) {
      is_prime.at(j) = false;
    }
  }
  return is_prime;
}

vector<int> is_like2017(vector<bool> is_prime) {
  vector<int> is_like2017(MAX, 0);
  for (int i = 0; i < MAX; i++) {
    if (i % 2 == 1 && is_prime.at(i) && is_prime.at((i+1)/2)) {
      is_like2017.at(i) = 1;
    }
  }
  return is_like2017;
}

int main() {
  auto is_prime = eratosthenes();
  auto a = is_like2017(is_prime);
  vector<int> cum_sum(MAX+1, 0);
  for (int i = 0; i < MAX; i++) {
    cum_sum.at(i+1) = cum_sum.at(i) + a.at(i);
  }
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int l, r;
    cin >> l >> r;
    cout << cum_sum.at(r+1) - cum_sum.at(l) << endl;
  }
}


Measured memory_bytes: 3380
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N, K;
   cin >> N >> K;
   int ans = 1e5;
   for (int mask = 0; mask < (1 << N); ++mask) {
      int tmp = 1;
      for (int i = 0; i < N; ++i) {
         if ((mask >> i) & 1) tmp *= 2;
         else tmp += K;
      }
      ans = min(ans, tmp);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#051_D
inf = 10 ** 10
n, m = map(int, input().split())
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    edges.append((a-1, b-1, c))

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
                
warshall_floyd(d)

ans = m
for u, v, c in edges:
    flg = False
    for i in range(n):
        if d[i][v] + c == d[i][u]:
            flg = True
    
    if flg:
        ans -= 1

print(ans)

Measured memory_bytes: 3444
import numpy as np

c = [list(map(int,input().split())) for i in range(3)]

A = np.array([
    [1,0,0,1,0,0],
    [1,0,0,0,1,0],
    [1,0,0,0,0,1],
    [0,1,0,1,0,0],
    [0,1,0,0,1,0],
    [0,1,0,0,0,1],
    [0,0,1,1,0,0],
    [0,0,1,0,1,0],
    [0,0,1,0,0,1]])

B = np.array([
    [1,0,0,1,0,0,c[0][0]],
    [1,0,0,0,1,0,c[0][1]],
    [1,0,0,0,0,1,c[0][2]],
    [0,1,0,1,0,0,c[1][0]],
    [0,1,0,0,1,0,c[1][1]],
    [0,1,0,0,0,1,c[1][2]],
    [0,0,1,1,0,0,c[2][0]],
    [0,0,1,0,1,0,c[2][1]],
    [0,0,1,0,0,1,c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print('Yes')
else:
    print('No')

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
    while(x!=parent[x]){
        parent[x] = parent[parent[x]];
        x = parent[x];
    }
    return x;
}

void sunion(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx != ry){
        if(Size[rx] > Size[ry]){
            parent[ry] = parent[rx];
            Size[rx] += Size[ry];
        }
        else{
            parent[rx] = parent[ry];
            Size[ry] += Size[rx];
        }
    }
}
*/

const ld PI = 3.141592653589793238;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        ld r;
        cin >> r;
        ld area = 2.0*PI*r;
        cout << area << "\n";
    }
    return 0;
}

Measured memory_bytes: 3796
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int[] a = r.ii();
        println(a[0] < a[1] ? 0 : 10);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var ACGT = "ACGT".ToCharArray();
            var S = Console.ReadLine();
            var max = 0;
            for(int i=0;i<S.Length;i++)
            {
                for(int k=i+1;k<=S.Length;k++)
                {
                    var tmp = S.Substring(i, k - i);
                    if (tmp.All(c=>ACGT.Contains(c)))
                    {
                        if (tmp.Length > max) max = tmp.Length;
                    }
                }
            }
            Console.WriteLine(max);
        }
    }

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100001];
LL sum, one;

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    one = (LL)n * (n + 1) / 2;
    sum = 0;
    forn(i, n) {
        sum += a[i];
    }
    if (sum % one != 0) {
        cout << "NO" << endl;
        return 0;
    }
    int cnt = sum / one;
    LL have = 0;
    a[n] = a[0];
    forn(i, n) {
        LL x = a[i + 1] - a[i] - cnt;
//        cerr << x << ' ';
        if (x > 0 || x % n != 0) {
            cout << "NO" << endl;
            return 0;
        }
        x *= -1;
        have += x / n;
    }
    if (have == cnt) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<string,int> mp;  //mp[string]
int num,n;
string s;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>s;
    	if(mp[s]) mp[s]++;//出现次数 
		else 
		{
		   num++;mp[s]=1;	             //mp[s]=0  
		 } 
	}
  cout<<num;
return 0;
}


Measured memory_bytes: 19260
#include <stdio.h>
#define INF 2e9

int min(int a,int b){
    if (a>b) return b;
    else return a;
}

int max(int a,int b){
    if (a>b) return a;
    else return b;
}

int main(){
  int i, n, r = -INF, m = INF, t;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&t);
    r = max(r,t-m);
    m = min(t,m);
  }
  printf("%d\n",r);
  
  return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll M{100000};
ll N,A[M],B[M],C[M],ans;
int main(){
    cin>>N;
    for(ll i{};i<N;++i)cin>>A[i];
    for(ll i{};i<N;++i)cin>>B[i];
    for(ll i{};i<N;++i)cin>>C[i];
    sort(A,A+N),sort(B,B+N),sort(C,C+N);
    for(auto& b:B)
        ans+=distance(A,lower_bound(A,A+N,b))*distance(upper_bound(C,C+N,b),C+N);
    cout<<ans<<endl;
}


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

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

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

int main(){
	ll n,w;
	ll x[102],y[102];
	scanf("%lld%lld",&n,&w);
	for(int i=0;i<n;i++)scanf("%lld%lld",&x[i],&y[i]);
	
	map<ll,ll> dp;
	dp[0]=0;
	for(int i=0;i<n;i++){
		auto itr=dp.end();
		while(itr!=dp.begin()){
			--itr;
			chmax(dp[itr->fr+x[i]],itr->sc+y[i]);
		}
	}
	
	ll ret=0;
	for(P p: dp)if(p.fr<=w)chmax(ret,p.sc);
	cout<<ret<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

bool possible(vi &arr,int mid,int k){
    int count = 0;
    rep(i,0,sz(arr)){
        if (arr[i]<=mid)continue;
        else count+= (arr[i])/mid;
        if (count>k)return false;
    }
    return true;
}

void solve(){
	//write here
   //WRWWRWRR -- > RRWWRWRW --> RRRWWRWWW
    int n,k;
    cin>>n>>k;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    int start = 1,end = 1e9+1;
    int ans;
    while (start<=end){
        int mid  = (start+end)/2;
        if (possible(arr,mid,k)){
            ans = mid;
            end = mid-1;
        }
        else start  = mid+1;
    }
    cout<<ans<<endl;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          string s = Input.ScanStr();
          int res = 700;
          for(int i=0;i<3;i++) if (s[i]=='o') res+=100;
          Console.WriteLine(res);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    int H, W;
    cin >> H >> W;

    VS A(H);
    REP(i, H) {
        cin >> A[i];
    }

    int count = 0;
    REP(i, H) {
        REP(j, W) {
            count += (A[i][j] == '#');
        }
    }

    if (count == H + W - 1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}

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

char dancestep[100010];

int dp[100010][10][2];
/****************
 *0,when the last step is left; 1 is right
 ****************/

int main()
{
    while (scanf("%s",dancestep+1)==1)
    {
        if (dancestep[1]=='#')
            break;
        dancestep[0]='5';
        // printf("%s",dancestep);
        int n=strlen(dancestep)-1;
        memset(dp, -1, sizeof(dp));

        int next=dancestep[1]-'0';
        for (int left=1; left<=9; left++)
            if(left!=5&&(left-1)%3+1<=(next-1)%3+1)
                dp[1][left][1]=0;
        for (int right=1; right<=9; right++)
            if(right!=5&&(next-1)%3+1<=(right-1)%3+1)
                dp[1][right][0]=0;

        for (int i=1; i<n; i++)
        {
            int left,right;
            int next=dancestep[i+1]-'0';

            left=dancestep[i]-'0';
            for (right=1; right<=9; right++)
                if (dp[i][right][0]>=0)
                {
                    // if (left!=next)
                    if ((left-1)%3+1<=(next-1)%3+1)
                        if (dp[i+1][left][1]==-1||dp[i+1][left][1]>dp[i][right][0])
                            dp[i+1][left][1]=dp[i][right][0];
                    //   if (next!=right)
                    if ((next-1)%3+1<=(right-1)%3+1)
                        if (dp[i+1][right][0]==-1||dp[i+1][right][0]>dp[i][right][0]+1)
                            dp[i+1][right][0]=dp[i][right][0]+1;
                }

            right=dancestep[i]-'0';
            for (left=1; left<=9; left++)
                if (dp[i][left][1]>=0)
                {
                    //  if (next!=right)
                    if ((next-1)%3+1<=(right-1)%3+1)
                        if (dp[i+1][right][0]==-1||dp[i+1][right][0]>dp[i][left][1])
                            dp[i+1][right][0]=dp[i][left][1];
                    //    if (left!=next)
                    if ((left-1)%3+1<=(next-1)%3+1)
                        if (dp[i+1][left][1]==-1||dp[i+1][left][1]>dp[i][left][1]+1)
                            dp[i+1][left][1]=dp[i][left][1]+1;
                }
        }
        int ans=-1;
        for (int i=1; i<=9; i++)
        {
            if (dp[n][i][0]>=0)
                if (ans==-1||ans>dp[n][i][0])
                    ans=dp[n][i][0];
            if (dp[n][i][1]>=0)
                if (ans==-1||ans>dp[n][i][1])
                    ans=dp[n][i][1];
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 8884
A = list(input())
B=[]
C=[]

for i in range(1,len(A),2):
  B.append(A[i])
for i in range(0,len(A),2):
  C.append(A[i])
B=set(B)
C=set(C)

if {'D', 'U', 'L'} >= B and {'D', 'U', 'R'} >= C:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>

#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()

using namespace std;

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

const int INF = 0x3c3c3c3c;
const ll LINF = 1ll*INF*INF*2;

const int MAX_N = 1000001;
int n;

vector<int> v;

int main(void) {
	scanf("%d", &n);n--;
	if(n==1) {
		printf("2 2\n1 2 0\n1 2 1");
		return 0;
	}
	int t = n;
	int dig=0;
	int cnt=0;
	while(t) {
		if(t&1) {
			cnt++;
			v.push_back(dig);
		}
		dig++;
		t>>=1;
	}
	printf("%d %d\n", dig, 2*dig+cnt-2);
	for(int i=1; i<dig; i++) printf("%d %d %d\n%d %d %d\n", i, i+1, 0, i, i+1, 1<<(i-1));
	int cur=0;
	for(int i=sz(v)-1; i>0; i--) {
		cur+=(1<<v[i]);
		printf("%d %d %d\n", v[i-1]+1, dig, cur);
	}
	printf("%d %d %d\n", 1, dig, n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

bool func(int n, int a, int b){
  int now = 0;
  while(n){
    now += n%10;
    n /= 10;
  }
  if(a <= now && now <= b) return true;
  return false;
}

int main(){
  int a,b,c,x; cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        int now = 500 * i + 100 * j + 50 * k;
        if(x == now) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const uint INF = (uint)(1<<31) - 1;

class RMQ {
  int N;
  vector<uint> dat;

  uint query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l)
      return INF;
    if (a <= l && r <= b)
      return dat[k];
    uint vl = this->query(a, b, k * 2 + 1, l, (l + r) / 2);
    uint vr = this->query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }

public:
  RMQ(int n) {
    N = 1;
    while(N < n)
      N *= 2;
    dat.clear();
    dat.resize(2 * N - 1, INF);
  }

  void update(int i, uint x) {
    i += N - 1;
    dat[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }

  uint query(int a, int b) {
    return query(a, b, 0, 0, N);
  }
};

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  RMQ r(n);
  for (int i = 0; i < q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0)
      r.update(x, y);
    else
      cout << r.query(x, ++y) << endl;
  }
}



Measured memory_bytes: 3880
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;

ll n , h[maxn] , dp[maxn] , k ; 
int main()
{
	migmig ;
	cin>>n>>k ; 
	for(int i = 1 ; i <= n ; i ++ )
	{
		cin>>h[i] ;
	}
	dp[1] = 0 ; 
	dp[2] = abs(h[2] - h[1]) ; 
	
	for(int i = 3 ; i <=n  ; i++ )
	{
		ll x = inf ; 
		for(int j = i -1 ; j >= 1 && j >= i - k ; j -- )
		{
			x = min(x , dp[j] + abs(h[i] - h[j])) ; 
		}
		dp[i] = x ; 
	}
	cout<<dp[n] ; 
}
//////
////////
///////////




Measured memory_bytes: 1792
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    set<int> a{1,3,5,7,8,10,12};
    set<int> b{4,6,9,11};
    set<int> c{2};
    int x,y;
    string result="No";
    cin >> x;
    cin >> y;
    if(a.count(x) && a.count(y)) result="Yes";
    if(b.count(x) && b.count(y)) result="Yes";
    if(c.count(x) && c.count(y)) result="Yes";
    cout << result << "\n";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(18);

	string s; cin >> s;

	if (sz(s) % 2) {
		cout << "No\n";
		return 0;
	}

	rep(i, 0, sz(s)) {
		char c = "hi"[i%2];
		if (s[i] != c) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	return 0;
}


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

int n;
std::vector <int> arr;

std::vector < std::vector <int> > ans;

void dfs(int x, std::vector <int> &v, int token) {
	if(x > n) {
//		printf("from here:");
//		for(int i = 0; i < v.size(); ++i) printf("%d ", v[i]);
//		putchar('\n');
		ans.push_back(v);
		return;
	}
	for(int i = 1; i <= token + 1; ++i) {
		v[x - 1] = i;
		dfs(x + 1, v, std::max(i, token));
	}
}

int main() {
	scanf("%d", &n);
	arr.resize(n);
//	for(int i = 0; i < arr.size(); ++i) printf("%d", arr[i]);
	dfs(1, arr, 0);
	std::sort(ans.begin(), ans.end());
	for(int i = 0; i < ans.size(); ++i) {
		for(int j = 0; j < ans[i].size(); ++j)
			putchar(ans[i][j] + 'a' - 1);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 9648
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	string s;
  	cin >> s;
  	while(s!=""){
      	ll sz = s.size();
    	if(s.substr(max(0LL,sz-7))=="dreamer"){
        	s=s.substr(0,sz-7);
        }else if(s.substr(max(0LL,sz-6))=="eraser"){
        	s=s.substr(0,sz-6);
        }else if(s.substr(max(0LL,sz-5))=="dream" || s.substr(sz-5)=="erase"){
        	s=s.substr(0,sz-5);
        }else{
        	cout << "NO" << endl;
          	return 0;
        }
    }
  	cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

ll N;
ll h[200];


int main() {

	cin >> N;
	repn(i, N) cin >> h[i];

	h[0] = 0;

	ll ans = 0;

	repn(i, 100) {
		repn(j, N) {
			if (h[j - 1] < i&&h[j] >= i) { ans++; }
		}
	}
	
	cout << ans;

	


	system("PAUSE");
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int w,h,n;
    cin >>w>>h>>n;
    int xl = 0, xr = w, yu = h, yd=0;
    
    for(int i = 0; i < n; i++)
    {
        int x,y,a;
        cin >> x>>y>>a;
        if(a==1)
        {
            xl =max(xl,x);
        }
        if(a==2)
        {
            xr=min(xr,x);
        }
        if(a==3)
        {
            yd=max(yd,y);
        }
        if(a==4)
        {
            yu=min(yu,y);
        }
    }
    
    cout<<(max(0,xr-xl) * max(0,yu-yd))<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll int mod=1e9+7;
int num[4],n;
double p[330][330][330];
double dp(int x,int y,int z){
    if(p[x][y][z]>=0)return p[x][y][z];
    double sum=(double)n/(x+y+z);
    if(x)sum+=dp(x-1,y,z)*x/(x+y+z);
    if(y)sum+=dp(x+1,y-1,z)*y/(x+y+z);
    if(z)sum+=dp(x,y+1,z-1)*z/(x+y+z);
    return p[x][y][z]=sum;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            for(int k=0;k<=n;k++)
                p[i][j][k]=-1;
    p[0][0][0]=0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        num[x]++;
    }
    printf("%.10lf\n",dp(num[1],num[2],num[3]));
    return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    char hm[26];
    for(int i=0;i<26;i++)
        hm[i] = '0';
    for(int i=0;i<s.length();i++){
        if(hm[s[i] - 'a'] == '0')
            hm[s[i] - 'a'] = t[i];
        if(t[i] != hm[s[i] - 'a']){
            cout<<"No";
            return 0;
        }
    }
    for(int i=0;i<26;i++)
        hm[i] = '0';
    for(int i=0;i<s.length();i++){
        if(hm[t[i] - 'a'] == '0')
            hm[t[i] - 'a'] = s[i];
        if(s[i] != hm[t[i] - 'a']){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


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

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

template<class T>
T read() {
    T x{};
    cin >> x;
    return x;
}

template<class T>
vector<T> read(int N){
    vector<T> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    return x;
}

template<class T>
void write(const T &x){ cout << x << endl; }

template<class T>
void write(const vector<T> &r){
    for(const auto &x : r){
        cout << x << " ";
    }
    cout << endl;
}

int main(){
    auto A = read<ll>();
    auto B = read<ll>();
    
    cout << max(0LL, A - 2* B) << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long int
#define S second
#define inf 1000000090
#define F first
#define sd(x) scanf("%d",&x)
#define nax 101000
#define mp make_pair
#define MOD 1000000007
#define pi pair<int ,int >
#define pii pair <int , pi> 
using namespace std;
int main(int argc, char const *argv[])
{
  // freopen("input.txt","read",stdin);
  // freopen("output.txt","write",stdout);
   int x;
   cin >> x;
   int val  = 0;
   for(int i=1;;i++)
   {
   		val+=i;
   		if(val == x)
   		{
   			cout << i  << "\n";
   			return  0;
   		}
   		if(val > x)
   		{
   			cout << i << '\n';
   			return 0;
   		}
   }
   return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

// read answer.

struct Floppy{
	int f[21];
	int roll;
	Floppy():roll(0){
	}
	bool cleared(){
		FOR(i, 1,9)if(f[0]!=f[i])return false;
		FOR(i, 1,3)if(f[15]!=f[15+i])return false;
		FOR(i, 1,3)if(f[18]!=f[18+i])return false;
		return true;
	}
	void rotate(int a, int b, int c, int d, int e, int g, int h){
		swap(f[a], f[b]);
		swap(f[g], f[h]);
		f[d]*=-1;
		if(f[c] == f[e]){
			f[c]=f[e]=f[e]*-1;
		}
	}
	void rotate_n(int t){
		if(t==0)rotate(18,20,0,1,2, 14, 15);
		else if(t==1)rotate(12,14,2,5,8, 18, 11);
		else if(t==2)rotate(9,11,6,7,8, 17, 12);
		else rotate(15, 17, 0, 3, 6, 20, 9);
	}
	// working my fucking hashing code
	int hash(){
		int res = 0;
		REP(i, 9){
			res |= f[i]==1;
			res<<=1;
		}
		res = _hash(res, 12,13,14);
		res = _hash(res, 18,19,20);
		res = _hash(res, 9, 10, 11);
		res = _hash(res, 15,16,17);
		return res;
	}
	int _hash(int res, int a, int b, int c){
		res |= f[a]==f[b];res<<=1;
		res |= f[c]==f[b];res<<=1;
		return res;
	}
//	bool operator<(const Floppy &a) const {
//		REP(i, 24){
//			if(f[i] != a.f[i])return f[i] < a.f[i];
//		}
//		return false;
//	}
};

int bfs(Floppy &f){
	queue<Floppy> q;
	set<int> s;
	q.push(f);
	s.insert(f.hash());
	for(;;){
		Floppy v,u = q.front();q.pop();
		if(u.cleared())return u.roll;
		u.roll++;
		REP(i,4){
			v=u;v.rotate_n(i);
			if(!EXIST(s, v.hash())){
				s.insert(v.hash());
				q.push(v);
			}
		}
	}
}

int n;

int main() {
	omajinai;
	cin >> n;
	REP(i,n){
		Floppy f;
		REP(j,9){
			cin>>f.f[j];
			f.f[j] = f.f[j] == 1 ? 1 : -1;
		}
		FOR(j, 9,21)cin>>f.f[j];
		int _;
		FOR(j, 21,30)cin>>_;
		int ans = bfs(f);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3252
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,f,j,ans,m;
    string s;
    cin >> s;
    n=s.length()/2;
    f=1;
    for(i=0;i<n;++i)
    {
        if(s[i]!=s[s.length()-i-1]) 
        {
            f=0;
            break;
        }
    }
    //cout << f << endl ;
    if(f==1)
    {
        m=n/2;
        for(i=0;i<m;++i)
        {
            if(s[i]!=s[n-i-1]) 
            {
                f=0;
                break;
            }
        }
        //cout << f << endl ;
        if(f==1)
        {
            ll t=s.length();
            for(i=0;i<m;++i)
            {
                if(s[i+n+1]!=s[s.length()-i-1])
                {
                    f=0;
                    break;
                }
                
            }
            if(f==1) cout << "Yes" ;
        }
        else cout << "No" ;
    }
    else cout << "No" ;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,c,d,e,i,j;
    cin >> a;
    e=a%10;
    d=((a%100)-e)/10;
    c=((a%1000)-d-e)/100;
    b=(a-c-e-d)/1000;
    if ((b==c&&c==d)||(c==d&&d==e))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 256
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
const ll X[]= {+0,+0,+1,-1,-1,+1,-1,+1};
const ll Y[]= {-1,+1,+0,+0,+1,+1,-1,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
// head collected

ll t, n, k, _, __,ans;
string str;

start;

    cin1(t);

    ll sum = 0;
    rep(i, 1, t+1)
        rep(j, 1, t+1)
            rep(k, 1, t+1){
                ans = gcd(i, j);
                ans = gcd(ans, k);
                sum += ans;
            }

    coul(sum);
     /*if( a == 7 || b == 7 || c ==  7 )
        coul("Yes");
     else
        coul( "No");*/



finish


Measured memory_bytes: 3660
int main()
{
    int N,A,B;
    scanf("%d",&N);
    if(10<=N && N<=99)
    {
    B=abs(N%10);
    A=abs(N/10);
    if(9 == A || 9 == B){
        printf("\nYes\n");
    }
    else printf("\nNo\n");
    }
return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    ll n, k = 6;
    cin >> n;
    for(int i = 1; i <= 5; ++i){ 
        cout << "0\n";
        if(i == n) break;
    }
    for(int i = 6; i <= n; ++i){
        ll ans = 0;
        for(int j = 1; j <= sqrt(i); ++j){
            for(int k = 1; k <= sqrt(i); ++k){
                for(int l = 1; l <= sqrt(i); ++l){
                    int a = (l*l) + (k*k) + (j*j) + (l*k) + (l*j) + (k*j);
                    if(a == i)
                        ++ans;
                    if(a > i)
                        break;
                }
            }
        }
        cout << ans << "\n";
    }
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <cstring>
#include <iomanip>
using namespace std;

double dp[301][301][301];
int main() {
  int n;
  cin >> n;
  int a;
  int cnt[3]= {0};
  for (int i = 0; i < n; ++i) {
    cin >> a;
    cnt[a-1]++;
  }
  int c1 = cnt[0] + cnt[1] + cnt[2];
  int c2 = cnt[1] + cnt[2];
  int c3 = cnt[2];

  dp[0][0][0] = 0;
  double dn = n;
  for (int k = 0; k <= c3; ++k) {
    double dk = k;
    for (int j = 0; j <= c2; ++j) {
      double dj = j;
      for (int i = 0; i <= c1; ++i) {
        double di = i;
        int c = i + j + k;
        if (c <= n && c > 0) {
          dp[i][j][k] = dn / c + di / c * (i > 0 ? dp[i-1][j][k]: 0) +
                                 dj / c * (j > 0 ? dp[i+1][j-1][k]: 0) + 
                                 dk / c * (k > 0 ? dp[i][j+1][k-1]: 0);
        }
      }
    }
  }
  cout << fixed << setprecision(14) << dp[cnt[0]][cnt[1]][cnt[2]] << '\n';
  return 0;
}


Measured memory_bytes: 111148
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    Q=int(input())
    prime_number=[True]*(10**5+1)
    prime_number[0]=prime_number[1]=False
    for i in range(2,int((10**5)**0.5)+1):
        if not prime_number[i]:
            continue
        for j in range(i*2,10**5+1,i):
            prime_number[j]=False
    like2017=[False]*(10**5+1)
    for i in range(1,10**5+1,2):
        if prime_number[i] and prime_number[(i+1)//2]:
            like2017[i]=True
    S=[0]*(10**5+2)
    for i in range(10**5+1):
        S[i+1]=S[i]+like2017[i]
    for _ in range(Q):
        l,r=map(int,input().split())
        print(S[r+1]-S[l])
    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 54104
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<char,LL>u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        u[a[0]]++;
    }
    cout<<(u['M']*u['A']*u['R'])+(u['M']*u['A']*u['C'])+(u['M']*u['A']*u['H'])+(u['M']*u['R']*u['C'])+(u['M']*u['R']*u['H'])+(u['M']*u['C']*u['H'])+(u['R']*u['C']*u['H'])+(u['A']*u['R']*u['C'])+(u['A']*u['R']*u['H'])+(u['A']*u['C']*u['H'])<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

typedef tuple<int, int, int> tup;

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

    int n;
    cin >> n;
    auto edge = initVec2<int>(n + 1, 0);
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<int> dep(n + 1, -1);
    vector<int> par(n + 1, 0);
    stack<tup> st;
    st.emplace(1, 1, 0);
    while(not st.empty()){
        int v, d, p;
        tie(v, d, p) = st.top();
        st.pop();
        if(dep[v] != -1){
            continue;
        }
        dep[v] = d;
        par[v] = p;
        for(int u : edge[v]){
            st.emplace(u, d + 1, v);
        }
    }

    int len = dep[n];
    int id = n;
    rep(i, len / 2){
        id = par[id];
    }

    vector<bool> used(n + 1, false);
    stack<int> sti;
    sti.push(n);
    while(not sti.empty()){
        int v = sti.top();
        sti.pop();

        if(used[v] || v == id){
            continue;
        }
        used[v] = true;
        for(int u : edge[v]){
            sti.push(u);
        }
    }

    int snuke = 0;
    rep(i, n + 1){
        if(used[i]){
            snuke++;
        }
    }

    int fennec = n - snuke;
    if(fennec > snuke){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }

    return 0;
}


Measured memory_bytes: 9600
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 100005;

vector <int> g[N];
bool used[N];
int path[N], n, m, ans;

void dfs (int v)
{
    used[v] = 1;
    for (auto i:g[v])
    {
        if (used[i]) path[v] = max(path[v], path[i]);
        else {
            dfs (i);
            path[v] = max(path[v], path[i]);
        }
    }
    path[v] ++;
    ans = max(path[v], ans);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i=1; i<=m; i++) {
        int v1, v2;
        cin >> v1 >> v2;
        g[v1].pb (v2);
	}
	for (int i=1; i<=n; i++) {
        if (!used[i]) dfs (i);
	}
	cout << ans-1;
    return 0;
}


Measured memory_bytes: 7424
// D - Remainder Reminder
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N,K; cin>>N>>K;
	ll cnt = 0, d = K!=0;
	for(ll b=K+1; b<=N; ++b) cnt += N/b * max(0LL, b-K) + max(0LL, N%b-K + d);
	cout<< cnt <<endl;
}

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

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
    // 入力
    ll N,M;
    cin>>N>>M;
    ll A[N+1];
    for(int i=1; i<=N;i++){
        cin>>A[i];
    }

    ll kmax=32; //log2(10^9)<30
    ll Aadd[N+1];
    Aadd[0]=0;
    for(int i=1; i<=N;i++){
        Aadd[i]=(Aadd[i-1]+A[i])%M;
    }
    sort(Aadd,Aadd+1+N);

    ll nsame=0;
    ll ans=0;
    for(int i=1; i<=N;i++){
        // cout<<Aadd[i]<<","<<ans<<endl;
        if(Aadd[i]==Aadd[i-1]) nsame++;
        if(Aadd[i]!=Aadd[i-1] || i==N) {
            if(nsame>0){
                if(Aadd[i-1]==0){
                    ans+=nsame*(nsame+1)/2;
                } else{
                    nsame++;   
                    ans+=nsame*(nsame-1)/2;
                }
                nsame=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
 
class Program{
    public static void Main(){
        int n=int.Parse(Console.ReadLine());
        string[] s=Console.ReadLine().Split(' ');
        int[] a=new int[n];
        for(int i=0; i<n; i++){
            a[i]=int.Parse(s[i]);
        }

        for(int i=1; i<n; i++){
            for(int k=0; k<n; k++){
                if(k>=n-1){
                    Console.WriteLine(a[k]);
                } else{
                    Console.Write(a[k]+" ");
                }
            }

            int key=a[i];
            int j=i-1;
            while(j>=0 && a[j]>key){
                a[j+1]=a[j];
                j--;
            }
            a[j+1]=key;
        }

        for(int k=0; k<n; k++){
            if(k>=n-1){
                Console.WriteLine(a[k]);
            } else{
                Console.Write(a[k]+" ");
            }
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int x1,x2,y1,y2,x,y;
  cin>>x1>>y1>>x2>>y2;
  x=x2-x1;
  y=y2-y1;
  cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
 
    bool * visited = new bool[n + 1];
    memset(visited, false, sizeof(visited));
 
    ll arr[n + 1] = {0};
    ll correct = 0, penalties = 0;
 
    for(ll i = 1; i <= m; i++)
    {
        ll k; string output;
        cin >> k >> output;
        if(visited[k])
        {
            continue;
        }
        else if(visited[k] == false && output[0] == 'A')
        {
            visited[k] = true;
            correct++; penalties += arr[k];
        }
        else if(visited[k] == false && output[0] == 'W')
        {
            arr[k]++;
        }
    }
 
    cout << correct << " " << penalties << endl;
 
 
    return 0;
}

Measured memory_bytes: 1152