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

long long g(long long x) {
  long long j;
   j = 1;
 for (long long i = 0; i < x; i++){
   j = (j * (i + 1)) % 1000000007;
 }
    return j;
  }

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  int MOD;
  MOD = 1000000007;
  int N;
  cin >> N;
  int K;
  cin >> K;
  long long A;
	for (int i = 0; i < K; i++) {
      if(i > N-K){
        cout << 0 << endl;
      }else{
    A = g(N-K+1) * g(K-1) % MOD * modinv(g(N-K-i)* g(i+1) % MOD * g(i) % MOD * g(K-1-i) % MOD, MOD) % MOD;
    cout << A << endl ;
	}
    }
}




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

int n;
vector<int> L;

void input(){
    cin>>n;
    L.resize(n);
    rep(i,n) cin>>L[i];
}

void src(){
    int count=0;
    int a,b,c;
    sort(L.begin(),L.end());
    rep(i,n-2){
        a = L[i];
        repi(j,i+1,n){
            b = L[j];
            repi(k,j+1,n){
                c = L[k];
                if(c-a<b and b<a+c) count++;
            }
        }
    }
    cout<<count;
    return;
}

int main(int argc,char* argv[]){
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
/*  ex9_2
    potter0723sw  */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100000

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    int i = 0,ans = 0;
    //入力を受け取る配列をヌル文字分まで確保
    char color,block[SIZE + 1];
    //最初のノードの指す先
    node *first = NULL;
    scanf("%s", block);
    //tmpを順番に見ていってもしスタックに何も入っていないかスタックの先頭と同じ色だったらスタックに入れていく。
    while(block[i] != '\0'){
        if(first == NULL || first->elem == block[i]){
            push(&first, block[i]);
        }else{
            pop(&first);
            ans += 2;
        }
        i++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4952
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  ll x;cin>>x;
  if(x%11>6)cout<<(x/11)*2 +2<<endl;
  else if(x%11<=6&&x%11>0)cout<<2*(x/11)+1<<endl;
  else if(x%11==0)cout<<2*(x/11)<<endl;
}





Measured memory_bytes: 256
{
  const run = (input: string) => {
    let split = input.trim().split("\n")
    const n = parseInt(split[0])
    const l = split[1].split(" ").map(v => parseInt(v))

    l.sort((a: number, b: number) => a - b)

    let count = 0
    for (let i = 0; i < n; i++) {
      for (let j = 0; j < i; j++) {
        for (let k = 0; k < j; k++) {
          if (l[k] !== l[j] && l[j] !== l[i] && l[k] + l[j] > l[i]) {
            count++
          }
        }
      }
    }

    return count
  }

  const Main = (input: string) => {
    console.log(run(input))
  };
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


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



int main(){
    ll n,ans,len;
    string m;
    cin >> n >> m;
    //vector<string> s(n);
    if(n>=3200){ cout << m << endl;return 0;}
    else cout << "red" << endl;
    //cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define R1(i, n) for(int i = 1; i <= n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	int n;
	S(n);
	vector<int> v(n);
	int ma = 1;
	R(i, n) {
		int num;
		S(num);
		v[i] = num;
		ma = max(ma, num);
	}
	vector<int> ve(ma + 1);
	set<int> s;
	R(i, n) {
		if (s.find(v[i]) != s.end()) ve[v[i]]++;
		else for (int j = v[i]; j <= ma; j += v[i]) ve[j]++;
		s.insert(v[i]);
	}
	int ans = 0;
	R(i, n) {
		if (ve[v[i]] <= 1) ans++;
	}
	P(ans);
}

Measured memory_bytes: 17276
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define MAX_N 16
#define rep(i,n) for(int i = 0;i < (n);i++)
#define show(x) cout<<(#x)<<": "<<x<<endl;
using namespace std;
typedef long long ll;



int N;
ll M;
vector<int> G[100005];
vector<ll> dp[100005];
int par_i[100005];
ll ans[100005];

ll dfs(int v,int p=-1){
    ll ret = 1;
    for(int i=0;i<G[v].size();i++){
        int tov= G[v][i];
        if(tov == p){
            par_i[v]=i;
            continue;
        }
        ret *= dfs(tov,v)+1;
        ret %= M;
    }
    if(p>=0){
        dp[v][par_i[v]]=ret;
    }
    return ret;
}

void dfs2(int v,int p=-1,ll ret = 0){
    vector<ll> Left(G[v].size()+1,1),Right(G[v].size()+1,1);
    for(int i=0;i<G[v].size();i++){
        int tov = G[v][i];
        ll mult;
        if(tov==p){
            mult = ret+1;
            mult%=M;
        }else{
            mult = dp[tov][par_i[tov]]+1;
            mult%=M;
        }
        Left[i+1]=(Left[i]*mult)%M;
    }
    for(int i=G[v].size()-1;i>=1;i--){
        int tov = G[v][i];
        ll mult;
        if(tov==p){
            mult = ret+1;
            mult%=M;
        }else{
            mult = dp[tov][par_i[tov]]+1;
            mult%=M;
        }
        Right[i-1]=(Right[i]*mult)%M;
    }
    for(int i=0;i<G[v].size();i++){
        int tov= G[v][i];//次のdfs2先
        if(tov == p){
            continue;
        }
        dp[v][i]=(Left[i]*Right[i])%M;
        dfs2(tov,v,dp[v][i]);
    }
    ans[v]=Left[G[v].size()];
    return;
}

int main(){
    cin>>N>>M;
    rep(i,N-1){
        int x,y;
        cin>>x>>y;
        x--,y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    rep(i,N){
        dp[i].resize(G[i].size(),0);
    }
    dfs(0);
    dfs2(0);
//    rep(i,N){
//        cout<<"dp["<<i<<"]: ";
//        rep(j,dp[i].size()){
//            cout<<"to"<<G[i][j]<<": "<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    rep(i,N){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 24704
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, H, M float64
	fmt.Scan(&A, &B, &H, &M)
	HH := H*30.0 + M*0.5
	MM := M * 6.0
	rad := (max(HH, MM) - min(HH, MM)) * math.Pi / 180.0
	ans := math.Sqrt(math.Pow(A, 2) + math.Pow(B, 2) - 2*A*B*math.Cos(rad))
	fmt.Println(ans)
}

func max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
    
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        String str = in.br.readLine();
        long K = Long.parseLong(str);
        int N = 50;
        long[] a = new long[N];
        Arrays.fill(a, 49);
        long sho = K/N;
        int amari = (int)(K%N);
        for(int i=0; i<N; i++) {
        	if(i<amari){
        		a[i] = 100 - amari + sho;
        	} else {
        		a[i] = 49 - amari + sho;
        	}
        }
    	out.println(N);
    	for(int i=0; i<N; i++) {
    		if(i>0)
    			out.print(" ");
    		out.print(a[i]);
    	}
    	out.println("");
        out.flush();
    }
    
}

class InputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
    	return br.readLine().split(delim);
    }
    
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    ll cnt = 0, min_ = INF, ans = 0;
    REP(i, n){
        if(a[i] < 0) cnt++;
        min_ = min(min_, abs(a[i]));
        ans += abs(a[i]);
    }
    if(cnt % 2 == 1) ans -= 2 * min_;
    cout << ans;
    return 0;
}

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

using ll=long long;
const ll MOD=1e9+7;

int main(){
  string S;
  cin >> S;
  int sum;
  string T;
  for (int i=0;i<(1<<3);i++){
    sum=S[0]-'0';
    T="";
    for (int j=0;j<3;j++){
      if(i&(1<<j)){
        sum+=(S[j+1]-'0');
        T+='+';
      }
      else{
        sum-=(S[j+1]-'0');
        T+='-';
      }
    }
    if(sum==7){
      cout<<S[0]<<T[0]<<S[1]<<T[1]<<S[2]<<T[2]<<S[3]<<"=7"<<endl;
      break;
    }
    
  }
  
  
}

Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  ll N;

  while (cin >> N) {
    if (N % 2 == 1 || N == 0) {
      cout << 0 << endl;
      continue;
    }

    ll count2 = 0;
    for (ll i = 2; i <= N; i *= 2) {
      count2 += N / i;
    }

    ll count5 = 0;
    for (ll i = 10; i <= N; i *= 5) {
      count5 += N / i;
    }

    cout << min(count2, count5) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <unordered_map>
#include <queue>
#include <array>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
const int mod = 998244353;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

int main() {
  //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<bitset<301>> v(n);
  for (int i = 0; i < n; ++i) {
    v[i].reset();
    for (int j = 0; j < m; ++j) {
      int t;
      cin >> t;
      v[i][j] = t;
    }
  }
  int r = 0;
  for (int j = 0; j < m && r < n; ++j) {
    for (int i = r + 1; i < n; ++i) if (v[i][j]) {
      swap(v[r], v[i]);
      break;
    }
    if (!v[r][j]) continue;
    for (int i = r + 1; i < n; ++i) if (v[i][j]) v[i] ^= v[r];
    ++r;
  }
  cerr << r << endl;
  ll res = mpow(2, m + n - 1) - mpow(2, n + m - r - 1);
  cout << (res % mod + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
ll GetDigit(ll num){
	int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main(){

	ll n;
	cin>>n;
	int t=10;
	for(int i=1; i<100001; i++){
		if(n<i)break;
		if(n%i==0){
			int t2=0;
			t2=max(GetDigit(i),GetDigit(n/i));
			t=min(t,t2);
		}
	}
	cout<<t<<endl;
	return 0;

}




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

const long MAX_N=10000000;
bool isPrime[MAX_N];

int main(){
	for(long i=2; i<=MAX_N; ++i)
		isPrime[i]=true;
		
	for(long i=2; i<=MAX_N; ++i){
		if(isPrime[i]){
			for(long j=2; i*j<=MAX_N; ++j) isPrime[i*j]=false;
		}
	}
	
	while(1){
		long n;
		scanf("%ld", &n);
		if(n==0) break;
	
		if(n%2==0) --n;
	
		for(long i=n; i>=13; i-=2){
			if(isPrime[i]&&isPrime[i-2]&&isPrime[i-6]&&isPrime[i-8]){
				printf("%ld\n", i);
				break;
			}
		}
	}	 

	return 0;
}

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

const ll INF = 100100100;
class BFS {
public:
  //グラフの隣接リスト表現
  using Graph = vector<vector<ll>>;
  //INF
  //ノードの数
  ll num_of_nodes;
  //隣接表現のリスト
  Graph G;
  //各リストの出次数
  vector<ll> deg;
  //始点からの距離を格納するvector
  vector<ll> dist;


  BFS(ll n) {
    num_of_nodes = n;
    G = vector<vector<ll>>(n);
    deg = vector<ll>(n, 0);
    dist = vector<ll>(n, INF);
  }

  //distを格納するvectorのgetter
  vector<ll> get_dist() {
    return dist;
  }

  Graph get_graph() {
    return G;
  }

  void graph_init(ll m) {
    for (ll i = 0; i < m; i++) {
      ll a, b;
      cin >> a >> b;
      a--; b--; //入力が１オリジンの場合

      /*無向グラフの場合、例えば(5,8),(8,5)は重複するクエリなので片方を弾く*/
      //vector<ll>::iterator itr1, itr2;
      auto itr1 = find(G[a].begin(), G[a].end(), b);
      auto itr2 = find(G[b].begin(), G[b].end(), a);
      if (itr1 == G[a].end() && itr2 == G[b].end()) {
        G[a].push_back(b); G[b].push_back(a); //重複を許さない
        deg[a]++; deg[b]++;
      }
    }
  }

  void bfs(ll start) {
    queue<ll> q;
    dist[start] = 0;
    q.push(start);

    while(!q.empty()) {
      ll now = q.front(); q.pop();
      for (ll i = 0; i < G[now].size(); i++) {
        ll v = G[now][i]; //今の頂点に隣接する頂点ｖ
        if (dist[v] != INF) continue;

        dist[v] = dist[now]+1;
        q.push(v);
      }
    }
  }
};

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> G(H);
  for (int i = 0; i < H; i++) {
    cin >> G[i];
  }

  BFS b = BFS(H * W);

  vector<int> dh = {0, -1, 0, 1};
  vector<int> dw = {1, 0, -1, 0};


  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      if (G[h][w] == '#') continue;

      for (int i = 0; i < 4; i++) {
        int w_ = w + dw[i], h_ = h + dh[i];
        if (w_ < 0 || h_ < 0 || h_ >= H || w_ >= W) continue;

        if (G[h_][w_] == '.') b.G[W * h + w].push_back(W * h_ + w_);
      }
    }
  }

  vector<vector<ll>> setup_graph = b.get_graph();
  vector<ll> init_dist = b.get_dist();

  int max = -100;
  for (int i = 0; i < H*W; i++) {
    b.bfs(i);
    vector<ll> dists = b.get_dist();

    for (int j = 0; j < dists.size(); j++) {
      if (dists[j] == INF) continue;
      max = max < dists[j] ? dists[j] : max;
    }
    b.G = setup_graph;
    b.dist = init_dist;
  }

  cout << max << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
long long N,M,a,i,m=1e9+7;long long f(int A){return A?A*f(A-1)%m:1;}main(){std::cin>>N>>M;std::cout<<(M^N?M>N+1||M<N-1?0:1:2)*f(N)*f(M)%m;}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    if(n < 10){
        cout << n << endl;
        return 0;
    }
    else if(n < 100){
        cout << 9 << endl;
        return 0;
    }
    else if(n < 1000){
        cout << n - 100 + 10 << endl;
        return 0;
    }
    else if(n < 10000){
        cout << 909 << endl;
        return 0;
    }
    else if(n < 100000){
        cout << n - 10000 + 910 << endl;
        return 0;
    }
    else cout << 90909 << endl;

return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 1e5+7;
const ll INF = 1e18;

ll n,W,dp[102][nax],w[102],v[102];

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n>>W;
	for (ll i=0;i<n;++i) cin>>w[i]>>v[i];
	
	for (ll i=0;i<n;++i){
		for (ll weight=0;weight<=W;++weight){
			
			dp[i+1][weight] = max(dp[i][weight],(weight >= w[i]) ? dp[i][weight-w[i]]+v[i] : 0);
			
		}
	}
	
/*	for (ll i=1;i<=n;++i){
		for (ll weight=0;weight<=W;++weight) cout<<dp[i][weight]<<" ";
		cout<<"\n";
	}
	cout<<"\n";*/
	
	cout<<dp[n][W]<<"\n";
}

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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  set<int> snk;
  for(int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for(int j = 0; j < d; j++) {
      int a;
      cin >> a;
      snk.insert(a);
    }
  }
  cout << (n - snk.size());
}

Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int a[10000000] = {};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a , b;
    cin >>  a >> b;
    reverse( b.begin() , b.end() );
    if( a == b ) cout << "YES";
    else cout << "NO"; 
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
vector<string> v;
int h,w,maxx=-1;
int main(){	
  cin>>h>>w;
  for(int i=0;i<h;i++){
    string s;
    cin>>s;
    v.push_back(s);
  }
  int U[h][w],D[h][w],L[h][w],R[h][w];
  memset(U,0,sizeof U);
  memset(D,0,sizeof D);
  memset(L,0,sizeof L);
  memset(R,0,sizeof R);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) if(v[i][j]=='.'){
      if(j==0) L[i][j]=1;
      else if(j>=1) L[i][j]=L[i][j-1]+1;
      if(i==0) U[i][j]=1;
      else if(i>0) U[i][j]=U[i-1][j]+1;
    }
  }
  for(int i=h-1;i>=0;i--){
    for(int j=w-1;j>=0;j--) if(v[i][j]=='.'){
      if(j==w-1) R[i][j]=1;
      else if(j<w-1) R[i][j]=R[i][j+1]+1;
      if(i==h-1) D[i][j]=1;
      else if(i<h-1) D[i][j]=D[i+1][j]+1;
    }
  }
    for(int i=0;i<h;i++) for(int j=0;j<w;j++)
      maxx=max(maxx,L[i][j]+R[i][j]+D[i][j]+U[i][j]);
      
    cout<<maxx-3;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    string b = "Yes";
    for (int i = 0; i < s.size(); i++) {
        if ('U' == s[i] || 'D' == s[i]) continue;

        if ((i+1) % 2) {
            if ('R' == s[i]) continue;
        } else {
            if ('L' == s[i]) continue;
        }
        b = "No";
        break;
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;

int main()
{
  int n,ans=0;
  in n;
  bool flag=false;

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(4*i+7*j==n)flag=true;
    }
  }
  if(flag==true)py;
  else pn;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,ans=1;
  string s;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    cin>>s;
    cout<<s<<endl;
    cout<<s<<endl;
  }
  return(0);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> ans(n);
    for(int i=1; i<=n; ++i) ans[a[i-1]-1] = i;
    rep(i,n) if(i==n-1) cout << ans[i] << endl; else cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    double r; cin >> r;
    cout << fixed << setprecision(9) << 2 * r * 3.141592 << endl;
}

Measured memory_bytes: 3744
def func(n, r_t):
    minV = r_t[0]
    maxV = r_t[1] - minV
    for i in range(1, n):
        maxV = max(maxV, r_t[i] - minV)
        minV = min(minV, r_t[i])
    return maxV


n = int(input())
r_t = [int(input()) for _ in range(n)]
print(func(n, r_t))


Measured memory_bytes: 13596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int p = Integer.parseInt(chr[0]);
			int q = Integer.parseInt(chr[1]);
			int r = Integer.parseInt(chr[2]);

			 System.out.println(p+q+r-Math.max(p, Math.max(q, r)));
		}
	}
}

Measured memory_bytes: 25420
import java.io.*;
import java.util.*;

class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine(){
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }

}



public class Main {

    public static PrintWriter out;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int s = sc.nextInt();
        int w = sc.nextInt();
        if (w>=s){
            out.println("unsafe");
        }else {
            out.println("safe");
        }
        out.close();
    }

}


Measured memory_bytes: 32736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e6+1;
int n,q;
int c[N];
int p[N];
int f[N];
int ans[N];
int lz[N];
vector<pair<int,int> >qr[N];
void push(int id){
	lz[id*2]+=lz[id];
	lz[id*2+1]+=lz[id];
	lz[id]=0;
}
void upd(int id,int l,int r,int ql,int qr,int v){
	if(l>qr || r<ql) return;
	if(ql<=l && r<=qr){
		lz[id]+=v;return;
	}
	push(id);
	int mid=(l+r)/2;
	upd(id*2,l,mid,ql,qr,v);
	upd(id*2+1,mid+1,r,ql,qr,v);
}
int qry(int id,int l,int r,int p){
	if(l==r) return lz[id];
	push(id);
	int mid=(l+r)/2;
	if(p<=mid) return qry(id*2,l,mid,p);
	else return qry(id*2+1,mid+1,r,p);
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> q;
	for(int i=1; i<=n ;i++){
		cin >> c[i];
		p[i]=f[c[i]];
		f[c[i]]=i;
	}
	for(int i=1; i<=q ;i++){
		int l,r;cin >> l >> r;
		qr[r].push_back({l,i});
	}
	for(int i=1; i<=n ;i++){
		upd(1,1,n,p[i]+1,i,1);
		for(auto c:qr[i]){
			ans[c.se]=qry(1,1,n,c.fi);
		}
	}
	for(int i=1; i<=q ;i++){
		cout << ans[i] << '\n';
	}
	
}


Measured memory_bytes: 72616
// C.

#include <iostream>
#include <list>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL n, a[200000], sum = 0, x = 0, ans = 1LL << 60;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n-1; ++i) {
		x += a[i];
		ans = min(ans, abs(sum - x - x));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int pt_t = 0;
		int pt_h = 0;

		for(int i=1; i<=n; i++){
			String wd_t = sc.next();
			String wd_h = sc.next();

			if(wd_t.compareTo(wd_h) > 0) {
				pt_t += 3;
			} else if(wd_t.compareTo(wd_h) < 0) {
				pt_h += 3;
			} else {
				pt_t++;
				pt_h++;
			}
		}

		System.out.println(pt_t + " " + pt_h);
	}

}

Measured memory_bytes: 29524
import java.util.Scanner;

public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int S[] = new int[100000];
        for(int i = 0; i < n; i++)
            S[i] = scanner.nextInt();
        int q = scanner.nextInt();
        int T[] = new int[50000];
        for(int i = 0; i < q; i++)
            T[i] = scanner.nextInt();
        scanner.close();

        int amount = 0;
        for(int i = 0; i < q; i++){
            if(search(0, n - 1, S, T[i]))
                amount++;
        }
        System.out.println(amount);
    }

    public static boolean search(int s, int e, int[] A, int p){
        if(s == e){
            if(A[s] == p)
                return true;
            else
                return false;
        }
        else{
            if(A[(s + e)/2] == p)
                return true;
            else if(A[(s + e)/2] > p)
                return search(s, (s + e)/2, A, p);
            else
                return search((s + e)/2 + 1, e, A, p);
        }
    }

}



Measured memory_bytes: 68408
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> v;

    int p = 0;
    int d = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        v.pback(tmp);

        if(tmp == i + 1) d++;
    }

    int index = 0;

    while(index + 1 <= n - 1){
        if(v[index] == index + 1 && v[index + 1] == index + 2){
            p++;
            index = index + 2;
        }else{
            index++;
        }
    }

    cout << d - p << endl;

    

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int x,y;
    x=max(a*c,b*c);
    y=max(a*d,b*d);
    y=max(x,y);
    cout<<y<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,k;
    cin>>a>>b>>k;
    ll k2=k-a;
    a-=k;
    if(k2>=0)b-=k2;
    puta(max(0,a), max(0,b));
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from math import sqrt
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from itertools import accumulate,permutations
from bisect import bisect_left,bisect_right

N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

states = list(permutations(list(range(N))))

ans = 0
for state in states:
    x,y = xy[state[0]]
    dist = 0
    for i in state[1:]:
        nx,ny = xy[i]
        dist += sqrt(pow(nx - x, 2) + pow(ny - y, 2))
        x,y = nx,ny
    ans += dist

print(ans / len(states))

Measured memory_bytes: 10068
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main()
{
	int h,w;
	cin >> h >> w;
	string grid[h];
	for(int i=0;i<h;i++)
		cin >> grid[i];
	int dp[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i == 0 && j == 0){
				dp[i][j] = 1;
				continue;
			}
			if(grid[i][j] == '#'){
				dp[i][j] = 0;
				continue;
			}
			if(j == 0)
				dp[i][j] = dp[i-1][j]%mod;
			else if(i == 0)
				dp[i][j] = dp[i][j-1]%mod;
			else
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
		}
	}
	cout << dp[h-1][w-1] << "\n";
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, K, S;
  cin >> N >> K >> S;

  vector<llong> ans(N, S);
  for (int i = K; i < N; ++i) {
    ans[i] = 46189;
  }

  for (auto &a: ans) {
    cout << a << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string.h>

using namespace std;

int ball_list[10];
int right_list[10];
int left_list[10];

bool flag;

void dfs(int right, int left){
  int count = right + left;

  if(count == 10){
    flag = true;
  }else{
    if(right == 0 || right_list[right-1] < ball_list[count]){
      if(right == 0){
        right_list[0] = ball_list[count];
      }else{
        right_list[right] = ball_list[count];
      }
      dfs(right+1, left);
    }
    if(left == 0 || left_list[left-1] < ball_list[count]){
      if(left == 0){
        left_list[0] = ball_list[count];
      }else{
        left_list[left] = ball_list[count];
      }
      dfs(right, left+1);
    }
  }
}

int main(){
  int n;

  cin >> n;

  for(int i = 0; i < n; i++){
    flag = false;
    memset(right_list, 0, sizeof(right_list));
    memset(left_list, 0, sizeof(left_list));

    for(int j = 0; j < 10; j++){
      cin >> ball_list[j];
    }
    
    dfs(0, 0);

    if(flag){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <functional>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long

using namespace std;


int main(void) {
    int n;
    while (cin>>n){
        int ans = 0;
        REP(a,10){
            REP(b,10){
                REP(c,10){
                    REP(d,10){
                        if (a+b+c+d==n)
                            ans++;
                    }
                }
            }
        }
        cout << ans <<endl;;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    ll n;
    cin >> n;
    ll b[n];
    for (ll i = 0; i < n - 1; i++) cin >> b[i];

    ll ans = b[0];
    for (ll i = 0; i < n - 2; i++){
        ans += min(b[i], b[i + 1]);
        // cout << ans << endl;
    }
    ans += b[n - 2];
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
vector<vector<int> > g;
int p[100000];
int DFS(int u) {
	if (u == n - 1)
		return 0;
	int ret = 1e9;
	for (int i = 0; i < g[u].size(); ++i) {
		if (g[u][i] != p[u]) {
			p[g[u][i]] = u;
			ret = min(ret, 1 + DFS(g[u][i]));
		}
	}
	return ret;
}
int DFS(int u, int p) {
	int ret = 1;
	for (int i = 0; i < g[u].size(); ++i)
		if (g[u][i] != p)
			ret += DFS(g[u][i], u);
	return ret;
}
int main()
{
	scanf("%d", &n);
	g.resize(n);
	for (int i = 1, a, b; i < n; ++i) {
		scanf("%d%d", &a, &b);
		--a; --b;
		g[a].push_back(b);
		swap(a, b);
		g[a].push_back(b);
	}
	int len = DFS(0);
	vector<int> v;
	int cur = n - 1;
	while (cur) {
		v.push_back(cur);
		cur = p[cur];
	}
	v.push_back(0);
	reverse(v.begin(), v.end());
	int x = v[(v.size() - 1) / 2];
	int y = v[(v.size() - 1) / 2 + 1];
	int A = DFS(x, y) - 1;
	int B = DFS(y, x) - 1;
	if (A > B)
		puts("Fennec");
	else
		puts("Snuke");
	return 0;
}

Measured memory_bytes: 11388
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

int main(){
    std::ios::sync_with_stdio(false);
    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    int threshold = a[p-1];
    int res = p-1;
    ll total_votes = v * m;
    ll cum_sum = 0;
    for(int i=p-1;i<n;++i)
    {
        if(threshold > (a[i] + m)) {
            cerr << "not reachable" << endl;
            cum_sum += a[i];
            continue;
        }
        int k = n - i;
        ll vote_consumable = (k + (p-1)) * m;
        if(vote_consumable >= total_votes) {
            cerr << "all safely consumable" << endl;
            res++;
            cum_sum += a[i];
            continue;
        }
        ll need_to_consume = total_votes - vote_consumable;
        ll capacity = (m + a[i]) * (n - k - (p - 1)) - cum_sum;
        if(capacity >= need_to_consume){
            cerr << "Can be selected" << endl;
            res++;
        }
        cum_sum += a[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 1152
#C
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
max_num = 0

for i in range(n):
    if a[i]-b[i] >= 0:
        a[i] -= b[i]
        max_num += b[i]
    elif a[i]-b[i] < 0:
        max_num += a[i]
        b[i] -= a[i]
        if a[i+1] - b[i] < 0:
            max_num += a[i+1]
            a[i+1] = 0
        else:            
            a[i+1] -= b[i]
            max_num += b[i]
        
print(max_num)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, N, res;
  rd(N);
  rd(A);
  res = N*N - A;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int N, A, res;
//   rd(N, A);
//   res = N*N - A;
//   wt(res);
// }


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

int main(){
    int n;
    cin >> n;
    if (n == 2){
        cout << -1 << endl;
        return 0;
    }

    vector<string>
    p3 = {
        ".aa",
        "b..",
        "b.."
    },
    p4 = {
        "aacd",
        "bbcd",
        "cdaa",
        "cdbb"
    },
    p5 = {
        "aabba",
        "bcc.a",
        "b..cb",
        "a..cb",
        "abbaa"
    },
    p6 = {
        ".aaccd",
        "b..f.d",
        "b..fee",
        "ccd.aa",
        "f.db..",
        "feeb.."
    },
    p7 = {
        ".aa.aac",
        "b..b..c",
        "b..b..b",
        ".aa.aab",
        "b..b..c",
        "b..b..c",
        "aaccaa."
    };

    int i = 0;
    vector<string> ans(n, string(n, '.'));
    auto add = [&](auto &p){
        for (int h = 0; h < p.size(); h++){
            for (int w = 0; w < p.size(); w++){
                ans[i + h][i + w] = p[h][w];
            }
        }
        i += p.size();
    };

    auto output = [&](){
        for (const auto &a: ans)
            cout << a << endl;
    };

    if (n == 3){
        add(p3);
        output();
        return 0;
    }

    if (n % 4 == 1){
        add(p5);
    } else if (n % 4 == 2){
        add(p6);
    } else if (n % 4 == 3){
        add(p7);
    }

    while(i < n)
        add(p4);

    output();
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
   int l, r;
   cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long int
#define sci(x) sca nf("%d",&x);
#define scd(x) scanf("%lf",&x);
#define pb(x) push_back(x)
#define FasterIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mkp(x,y) make_pair(x,y)
#define pii pair<int , int>
#define SEIVE seive(){ prime[1]=1; for(ll i=2; i*i<=1000000; i++) { if(prime[i]) continue; for(ll j=i*i; j<=1000000; j+=i) prime[j]=1; } }
bool prime[1000006];
vector<int>vec[20000],root;
int vis[20002];


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

    while(n!=0)
    {
        int k=(n%26);
        if(k==0)
        {
            k=26;
        }
        s+=char(k+'a'-1);
        n=n-k;
        n=n/26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int n;
	cin >> n;
	cout << n*n*n << endl;
}

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

using namespace std;
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;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}
template<typename T>
struct edge {
  int from, to;
  T cost;

  edge(int from, int to) : from(from), to(to), cost((T)1) {}

  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<typename T>
using Edges = std::vector<edge<T>>;

template<typename T>
std::vector<std::vector<T>> warshall_floyd_ret(const Edges<T> &edges, const int n, const T INF) {
  std::vector<std::vector<T>> distance(n, std::vector<T>(n, INF));
  for(auto &e : edges) {
    distance[e.from][e.to] = e.cost;
  }
  for(int i = 0; i < n; ++i) distance[i][i] = 0;
  for(int k = 0; k < n; ++k) {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        if(distance[i][k] == INF || distance[k][j] == INF) continue;
        else distance[i][j] = std::min(distance[i][j], distance[i][k] + distance[k][j]);
      }
    }
  }

  return distance;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  ll l;
  cin >> n >> m >> l;
  Edges<ll> edges1;
  Edges<ll> edges2;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    edges1.emplace_back(a, b, c);
    edges1.emplace_back(b, a, c);
  }
  VVL dis = warshall_floyd_ret(edges1, n, LINF);
  rep(i, n) rep(j, n) {
    if(dis[i][j] <= l && i != j) edges2.emplace_back(i, j, 1);
  }
  VVL count = warshall_floyd_ret(edges2, n, LINF);
  int q;
  cin >> q;
  VL ans;
  while(q) {
    int s, t;
    cin >> s >> t;
    ans.push_back(count[--s][--t]);
    q--;
  }
  for(auto a : ans) {
    a == LINF ? out(-1) : out(a - 1);
  }

  return 0;
}


Measured memory_bytes: 6388