akhauriyash/Code-Regression huggingface dataset:
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../bits/stdc++.h"
#endif

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

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N;

bool input(){
  cin>>N;
  return N;
}

void solve(){
  int c=0;
  for(int i=1;i+i+1<=N;i++) {
    int s=i;
    for(int j=1;s<N;j++) {
      s+=i+j;
    }
    if(s==N)c++;
  }
  cout<<c<<endl;
}

int main(){
  cin.tie(0);
  
  while (input()){
      solve();
  }
  
  return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int ans;
int K;
void input() {
  cin >> N >> K;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
}
void solve() {
  vb.resize(N + 1);
  partial_sum(all(va), vb.begin() + 1);
  debugv(va);
  debugv(vb);
  map<int, int> mp;
  // map[vb[j]-j] : 条件を満たすiの個数
  each(x, vb) x %= K;
  queue<int> q;
  rep(i, 0, N) {
    int ci = (vb[i] - i + K * (i + 1)) % K;
    ans += mp[ci];
    debug2(i, ans);
    mp[ci]++;

    q.push(ci);
    if (q.size() >= K) {
      mp[q.front()]--;
      q.pop();
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 17548
#include <bits/stdc++.h>
#include <algorithm>  
#include <bitset>
#include <sstream>
#include <string>
 
 
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,k,h[200000],dp[200000];
    cin>>n>>k;
    for(long long int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    for(long long int i=1;i<n;i++)
    {
        long long int mini=1e9;
        for(long long int j=1;j<=k;j++)
        {
            if(i-j<0)
                break;
            else
            {
                long long int temp;
                if(h[i]>h[i-j])
                    temp=h[i]-h[i-j];
                else
                    temp=h[i-j]-h[i];
                mini=min(mini,dp[i-j]+temp);
            }
        }
        dp[i]=mini;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5240
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
h = readInts()
ans = 0
while h.count(0)!=n:
  boo = 0
  for i in range(len(h)):
    if h[i]!=0:
      if boo==0:
        boo=1
        ans+=1
      h[i]-=1
    else:
      boo=0

print(ans)

Measured memory_bytes: 9332
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    reverse(all(s));
    VV dp(s.size() + 1, V(2));
    dp[0][0] = 1;
    rep(i,s.size()){
        if(s[i]=='1'){
            dp[i + 1][0] += dp[i][1] + dp[i][0] * 3;
            dp[i + 1][1] += dp[i][1]*2;
        }else{
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][1] * 3 + dp[i][0]*2;
        }
        dp[i+1][0]%=MOD;
        dp[i+1][1]%=MOD;
    }
    cout << dp[s.size()][0] << endl;
}

Measured memory_bytes: 5840
from sys import stdin
import math
import heapq
#V:num of vertices
#E: num of edges
#r: start vertex
V, E, r = map(lambda x: int(x), stdin.readline().split(' '))

#create adjacency_list
adjacency_list = [[] for x in range(V)] #size V
for i in range(E):
    s, t, d = map(lambda x: int(x), stdin.readline().split(' '))
    adjacency_list[s].append([t, d])

distance = [(math.inf, id) for id in range(V)]
output_distance = [math.inf for id in range(V)]
checked_set = set()
distance[r] = (0, r)

distance.sort()
while len(checked_set) < V:
    target = heapq.heappop(distance)
    target_id = target[1]
    if target_id in checked_set:
        continue
    target_dis = target[0]
    output_distance[target_id] = target_dis
    for i in adjacency_list[target_id]:
        if i[1] + target_dis < output_distance[i[0]]:
            heapq.heappush(distance, ((i[1] + target_dis, i[0])))
    checked_set.add(target_id)
    
for dis in output_distance:
    if dis == math.inf:
        print('INF')
    else:
        print(dis)


Measured memory_bytes: 120088
def solve():
    N,Q = map(int, input().split())
    S = input()
    AC_total = [0]*N
    for i in range(1,N):
        AC_total[i] = AC_total[i-1]
        if S[i-1] == 'A' and S[i] == 'C':
            AC_total[i] += 1
        
    
    # print(AC_total)
    for _ in range(Q):
        l,r = map(int, input().split())
        print(AC_total[r-1]-AC_total[l-1])
        
solve()

Measured memory_bytes: 6188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
using namespace std;
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;cin >> n;
    int a[100001];
    rep(i, n){cin >> a[i];}
    int g = a[0];
    rep(i, n){
        g = gcd(a[i], g);
    }
	cout << g << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define swap(x,y) int (temp)=int (x);(x)=int (y);(y)=(temp);
#define ll long long
#define S string
#define len(a)	string (a).length()
#define arn 100000
#define forn(a,b) for(int (a)=1;a<=int (b);a++)
#define for3(a,b,c) for(int (a)=int (c); a<=int(b);a++)
int main()
{
	ll n;
	ll x;
	ll y;
	ll alice=0,bob=0;
	ll num[arn];
	cin>>n;
	forn(x,n)
	{
		cin>>num[x];
	}
	forn(x,n-1)
	{
		for3(y,n,x+1)
		{
			if(num[x]<num[y])
			{
				swap(num[x],num[y])
			}
		}
	}
	x=1;
	while(x<=n)
	{
		if(x%2==1)
		{
		alice=alice+num[x];
		}
		else if(x%2==0)
		{
			bob+=num[x];
		}
		x++;
	}
	cout<<alice-bob<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main(){
    let (a,b) = (read::<i32>(),read::<i32>());
    let mut r = 0;
    for i in a..b+1{
        if kaibun(i){
            r += 1;
        }
    }
    println!("{}",r)
}
fn kaibun(num : i32) -> bool{
    let nums = format!("{}", num).chars().collect::<Vec<char>>();
    let l = nums.len();
    for i in 0..l/2{
        if nums[i] != nums[l-1-i]{
            return false
        }
    }
    true
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n;
int a[1000100];
int mod2(int n,int r){
	int delta=(r|(n-r));
	if(n==delta)
		return 3;
	return 0; 
}
void Out(int ans){
	printf("%d\n",ans);
	exit(0);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%1d",&a[i]);
		a[i]--;
	}
	int x=0,y=0;
	for(int i=0;i<n;i++){
		x^=(mod2(n-1,i)&a[i]);
		y|=a[i];
	}
	if(x&1)
		Out(1);
	else if(y&1)
		Out(0);
	else if(x&2)
		Out(2);
	else
		Out(0);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  vector<vector<int>> t(3, vector<int>(3));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> t.at(i).at(j);
    }
  }

  if(t.at(0).at(1) - t.at(0).at(0) == t.at(1).at(1) - t.at(1).at(0) &&
     t.at(0).at(1) - t.at(0).at(0) == t.at(2).at(1) - t.at(2).at(0) &&
     t.at(0).at(2) - t.at(0).at(0) == t.at(1).at(2) - t.at(1).at(0) &&
     t.at(0).at(2) - t.at(0).at(0) == t.at(2).at(2) - t.at(2).at(0)){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
  
  //cout << t.at(1).at(1) << endl;
  
  /*
  cout << t.at(0).at(1) - t.at(0).at(0) - ( t.at(1).at(1) - t.at(1).at(0) ) << " ";
  cout << t.at(0).at(1) - t.at(0).at(0) - ( t.at(2).at(1) - t.at(2).at(0) ) << " ";
  cout << t.at(0).at(2) - t.at(0).at(0) - ( t.at(1).at(2) - t.at(1).at(0) ) << " ";
  cout << t.at(0).at(2) - t.at(0).at(0) - ( t.at(2).at(2) - t.at(2).at(0) ) << " ";
  */
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%inf;
        b/=2;
        x=x*x%inf;
    }
    return res;
}
signed main(){
    ll n;cin>>n;
    vector<ll>a(n+2);
    REP(i,1,n+1){
        cin>>a[i];
    }
    vector<ll>k(n+1);
    k[0]=1;
    REP(i,1,n+1){
        k[i]=k[i-1]*i%inf;
    }
    vector<ll>kk(n+1);
    REP(i,1,n+1){
        kk[i]=k[n]*rui(i,inf-2)%inf;
    }
    vector<ll>kkk(n+1);
    REP(i,1,n+1){
        kkk[i]=(kkk[i-1]+kk[i])%inf;
    }
    ll ans=0;
    REP(i,1,n+1){
        ans=(ans+(kkk[n+1-i]-kkk[1])%inf*a[i])%inf;
        ans=(ans+(kkk[i])*a[i]%inf)%inf;
    }
    if(ans<0)ans+=inf;
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    int len;
    
    while (getline(cin, s)) {
        while (1) {
            len = s.size();
            for (int i = 0; i < len; i++) {
                if ('a' <= s[i] && s[i] <= 'z') {
                    if (s[i] == 'a') {
                        s[i] = 'z';
                    }
                    else {
                        s[i]--;
                    }
                }
            }
            int res1 = s.find("the");
            int res2 = s.find("this");
            int res3 = s.find("that");
            if ((res1 >= 0 && res1 < 80) || (res2 >= 0 && res2 < 80) || (res3 >= 0 && res3 < 80)) {
                cout << s << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1176
n, m = map(int, input().split())
a = []
b = []

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(int(input()))
    
for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)


Measured memory_bytes: 6012
#include <stdio.h>
#include <math.h>
 
double memo[150][150];
 
int main(void){
  int i,j,h,w;
  int min,now,nh,nw,nnh,nnw;
  while(1){
    scanf("%d%d",&h,&w);
    if(h+w==0)break;
    //if(h<w-1)printf("%d %d\n",h+1,w);
    //else{
    now = h*h+w*w;
    min = now*1500;
    nh = 150;
    nw =150;
    nnh = 150;
    nnw = 150;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
    //if(i*i+j*j==4069)printf("%d %d %d %d %d\n",now,min,i*i+j*j,i,j);
    if(now==i*i+j*j&&h<i&&nnh>i){
      //printf("a%d %d\n",i,j);
      nnw = j;
      nnh = i;
    }
    if(now<i*i+j*j&&min>=i*i+j*j){
      //printf("%d %d %d %d %d\n",now,min,i*i+j*j,i,j);
      if(min==i*i+j*j&&nh>i){
        nh = i;
        nw = j;
      }
      else if(min>i*i+j*j){
        nh = i;
        nw = j;
        min = i*i+j*j;
      }
    }
      }
    }
    if(nnh != 150){
      nh = nnh;
      nw = nnw;
    }
    printf("%d %d\n",nh,nw);
  }
  return 0;
}



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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

constexpr double pi = acos(-1.0);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  h += m / 60;
  cout << hypot(b * cos(h / 6 * pi) - a * cos(m / 30 * pi), b * sin(h / 6 * pi) - a * sin(m / 30 * pi)) << '\n';
}


Measured memory_bytes: 4144
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] dp = new int[201];
        dp[0] = 0;
        for(int i=1; i<=200; i++) {
            dp[i] = dp[i-1];
            int count = 0;
            if(i % 2 == 0) {
                continue;
            }
            for(int j=1; j<=i; j++) {
                
                if(i % j == 0) {
                    count++;
                }
            }
            if(count == 8) {
                dp[i]++;
            }
        }
        System.out.println(dp[N]);
        
    }
    
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int ans = 0;
    inc(i, 0, n){
        int a;cin >> a;
        while(a%2 == 0){
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

ll cmb(ll K) {
  return K*(K-1)%mod * modinv(2, mod) % mod;
}

int main() {
  int N, i, j;
  ll K, r, t=0, s=0;
  cin >> N >> K;
  vector<int> A(N);
  
  for(i=0; i<N; i++)
    cin >> A.at(i);
  
  for(i=0; i<N-1; i++)
    for(j=i+1; j<N; j++)
      if(A.at(i)>A.at(j)) {
        t++;
        t%=mod;
      }
  
  for(i=0; i<N; i++)
    for(j=0; j<N; j++)
      if(A.at(i)>A.at(j)) {
        s++;
        s%=mod;
      }
  
  r=t*K%mod+cmb(K)*s%mod;
  
  cout << r%mod << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
ll mod=1000000007;
ll x[100100];
ll y[100100];
int main(){
    ll n,m;
    while(~scanf("%lld%lld",&n,&m)){
        ll ans=0;
        for(int i=1;i<=n;i++) scanf("%lld",&x[i]);
        for(int i=1;i<=m;i++) scanf("%lld",&y[i]);

        ll Mx=0;
        for(ll i=1;i<n;i++){
            ll mid=i*(n-i)%mod*(x[i+1]-x[i])%mod;
//            printf("mid=%lld\n",mid);
            Mx=(Mx+mid)%mod;
        }
//        printf("Mx=%lld\n",Mx);
        ll My=0;
        for(ll i=1;i<m;i++){
            ll mid=i*(m-i)%mod*(y[i+1]-y[i])%mod;
            My=(My+mid)%mod;
        }
        ans=Mx*My%mod;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1664
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
ans = 'keyence'
S = input()
lenS = len(S)
for i in range(1,7):
    #print(ans[i:],S[lenS-7 + i:])
    #print(ans[:i], S[:i])
    if ans[:i] == S[:i] and ans[i:] == S[lenS - 7 + i:]:
        print('YES')
        exit()
print('NO')


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

    vi A(N), B(N);
    int idx=0, nmax=0;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        if (nmax < A[i]) {
            idx = i;
            nmax = A[i];
        }
    }

    cout << A[idx] + B[idx] << endl;



    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

string ch(string s, string &a, string &b){
    auto p = s.find(a);
    while(p != string::npos){
        s.replace(p, a.size(), b);
        p = s.find(a, p + b.size());
    }
    return s;
}

int main() {
    int n;
    while(cin >> n, n){
        vector<string> a(n), b(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i] >> b[i];
        }
        string s, t;
        cin >> s >> t;
        vector<vector<string>> v(10);
        map<string, int> X;
        v[0].emplace_back(s);
        X[s] = 0;
        for (int i = 0; i < 9; ++i) {
            for (auto &&j : v[i]) {
                for (int k = 0; k < n; ++k) {
                    string u = ch(j, a[k], b[k]);
                    if(!X.count(u)){
                        v[i+1].emplace_back(u);
                        X[u] = i+1;
                    }
                }
            }
        }
        if(X.count(t)) cout << X[t] << "\n";
        else puts("-1");
    }

    return 0;
}


Measured memory_bytes: 123596
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    edge = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)

    dist = [f_inf] * n
    dist[0] = 0
    q = deque([0])
    while q:
        u = q.popleft()
        if u != n - 1:
            for nv in edge[u]:
                if dist[nv] == f_inf:
                    dist[nv] = dist[u] + 1
                    q.append(nv)

    half_dist = (dist[-1] - 1) // 2
    dist2 = [f_inf] * n
    dist2[-1] = 0
    q = deque([n - 1])
    while q:
        u = q.popleft()
        for nv in edge[u]:
            if dist[nv] == f_inf:
                continue
            else:
                if dist2[nv] == f_inf:
                    if dist2[u] + 1 <= half_dist:
                        dist2[nv] = dist2[u] + 1
                        q.append(nv)

    visited = [False] * n
    visited[0] = True
    q = deque([0])
    while q:
        u = q.popleft()
        if u != n - 1:
            for nv in edge[u]:
                if dist2[nv] == f_inf and not visited[nv]:
                    visited[nv] = True
                    q.append(nv)

    fennec = sum(visited)
    snuke = n - fennec
    print("Fennec" if fennec > snuke else "Snuke")


if __name__ == '__main__':
    resolve()


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

const ll mod=1000000007;

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

 ll n,m;
  cin >> n >> m;
  vector<ll> s(n),t(m);
  rep(i,0,n) cin >> s[i];
  rep(i,0,m) cin >> t[i];
  
  vector<vll> dp(n+1,vll(m+1,0));
  rep(i,0,n+1) dp[i][0]=1;
  rep(i,0,m+1) dp[0][i]=1;
  
  rep(i,0,n){ 
    rep(j,0,m) {
      dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1])%mod;
      if(s[i]!=t[j]) dp[i+1][j+1]+=mod-dp[i][j];
      dp[i+1][j+1]%=mod;
                    }
  }
cout << dp[n][m] << endl;
  
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  double ans = double(w)*double(h)/2.0;
  printf("%.10lf %d\n",ans,(2*x == w) && (2*y == h));

  return 0;
}

Measured memory_bytes: 3720
n,k=map(int,input().split())
a=list(map(int,input().split()))

#左からi個、k種類選んだ場合
#dp[i][k]=cost



result=10**100
for i in range(2**(n-1)):
    #print(bin(i))
    if str(bin(i)).count("1")>=k-1:
        #print(">>>>>>",bin(i))
        bk=a[0]
        cost=0
        for j in range(n-1):
            if i>>j&1:
                if bk<a[j+1]:
                    bk=a[j+1]
                else:
                    bk+=1
                    cost+=(bk-a[j+1])
            else:
                bk=max(bk,a[j+1])
                #print(bk,a[j+1],bk-a[j+1])
        result=min(cost,result)
print(result)



Measured memory_bytes: 41072
from bisect import bisect_left
class BIT:
    def __init__(self,N):
        self.N=N
        self.bit=[0]*N
    def add(self,a,w):
        x=a
        while(x<self.N):
            self.bit[x]+=w
            x|=x+1
    def get(self,a):
        ret,x=0,a-1
        while(x>=0):
            ret+=self.bit[x]
            x=(x&(x+1))-1
        return ret
    def cum(self,l,r):
        return self.get(r)-self.get(l)

N,K=map(int,input().split())
a=[int(input()) for i in range(N)]
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=cum[i]+a[i]
B=[cum[i]-i*K for i in range(N+1)]

dic={}
li=sorted(B)
for i in range(N+1):
    dic[B[i]]=bisect_left(li,B[i])
bit=BIT(N+1)
ans=0
for i in range(N+1):
    ans+=bit.get(dic[B[i]]+1)
    bit.add(dic[B[i]],1)
print(ans)

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

const int maxn = 200010;
int N,cnt,side[maxn],nxt[maxn],toit[maxn],L[maxn],R[maxn];

inline void add(int a,int b) { nxt[++cnt] = side[a]; side[a] = cnt; toit[cnt] = b; }
inline void ins(int a,int b) { add(a,b); add(b,a); }

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline bool dfs(int now,int fa)
{
	if ((R[now]-L[now])&1) return false;
	if (L[now] > R[now]) return false;
	for (int i = side[now];i;i = nxt[i])
	{
		if (toit[i] == fa) continue;
		L[toit[i]] = max(L[toit[i]],L[now]-1);
		R[toit[i]] = min(R[toit[i]],R[now]+1);
		if (!dfs(toit[i],now)) return false;
		L[now] = max(L[now],L[toit[i]]-1);
		R[now] = min(R[now],R[toit[i]]+1);
		if ((R[now]-L[now])&1) return false;
		if (L[now] > R[now]) return false;
	}
	return true;
}

inline void print(int now,int fa)
{
	L[now] = R[now];
	for (int i = side[now];i;i = nxt[i])
	{
		if (toit[i] == fa) continue;
		L[toit[i]] = max(L[toit[i]],L[now]-1);
		R[toit[i]] = min(R[toit[i]],R[now]+1);
		print(toit[i],now);
	}
}
	

inline bool can() { if (!dfs(1,0)) return false; print(1,0); return true; }

int main()
{
	//freopen("C.in","r",stdin);
	//freopen("C.out","w",stdout);
	N = gi();
	for (int i = 1;i < N;++i) ins(gi(),gi());
	for (int i = 1;i <= N;++i) L[i] = -(1<<29),R[i] = 1<<29;
	for (int K = gi(),a;K--;) a = gi(),L[a] = R[a] = gi();
	if (can())
	{
		puts("Yes");
		for (int i = 1;i <= N;++i) printf("%d\n",L[i]);
	}
	else puts("No");
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;

const LL MOD = 1e9 + 7;

inline LL mod_add(LL a, LL b) {
    return (a + b) % MOD;
}

inline LL mod_sub(LL a, LL b) {
    return (a + MOD - b) % MOD;
}

inline LL mod_mul(LL a, LL b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}

LL mod_bipow(LL x, LL y) {   // power using bisection method
    if (y == 0) return 1;
    else if (y == 1) return x % MOD;
    else if (y % 2 == 0) {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(val, val);
    } else {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(mod_mul(val, val), x);
    }
}

LL mod_inv(LL x) {   // compute x^{-1}=x^{MOD-2} (when MOD is a prime number) using Fermat theorem
    return mod_bipow(x, MOD - 2);
}

LL mod_div(LL a, LL b) {   // using a/b=a*b^{-1}
    return mod_mul(a, mod_inv(b));
}


int main() {
	LL N;
	string S;
	cin >> N;
	cin >> S;

	multiset<char> count;
	set<char> taken;
	REP(i, N) {
		count.insert(S[i]);
	}
	LL ans = 1;
	EACH(x, count) {
		if (taken.count(x) != 0) {
			continue;
		} else {
			ans = mod_mul(mod_add(count.count(x), 1), ans);
			taken.insert(x);
		}
	}

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


Measured memory_bytes: 4992
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
odd = 1
for i in A:
    if i%2 == 0:
        odd *= 2
    else:
        odd *= 1
print(3**n - odd)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll n , x;
    cin >> n >> x;
    vl v , diff;
    forn(i , 1 ,n ){
       ll x;
       cin >> x;
       v.pb(x);
    }
    if(n == 1){
        cout << abs(v[0] - x) <<el ;
        ro;
    }
    v.pb(x);
    sort(v.begin() , v.end());
    forn(i , 0 , n-1){
      ll foo = abs(v[i]-v[i+1]);
      diff.pb(foo);
     }

     sort(all(diff));
     ll ziz = 0;
     ziz = __gcd(ziz , diff[0]);
     forn(i , 1 , diff.size()-2){
        ziz = __gcd(ziz, diff[i+1]);
     }
     cout << ziz << el ;
     ro ;
}























Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  string a;
  cin >> a;
  cout << ((a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) ? "Bad" : "Good")
       << endl;
}

Measured memory_bytes: 256
while(True):
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        exit()

    count = 0
    for a in range(1, n+1):
        for b in range(1, n+1):
            for c in range(1, n+1):
                if a < b < c and a + b + c == x:
                    count += 1
    print(count)


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

const int INF = INT_MAX;

int main(){
    int n;
    cin >> n;
    int zmax = -INF;
    int zmin = INF;
    int wmax = -INF;
    int wmin = INF;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        int z = x + y;
        int w = x - y;
        zmax = max(zmax, z);
        zmin = min(zmin, z);
        wmax = max(wmax, w);
        wmin = min(wmin, w);
    }
    cout << max(zmax - zmin, wmax - wmin) << endl;
    return 0;
}

Measured memory_bytes: 3552
A500 = int(input())  # ここで標準入力
B100 = int(input()) #ここで標準入力
C50 = int(input()) #ここで標準入力
X = int(input()) #ここで標準入力
out = 0

for a in range(A500+1):
    for b in range(B100+1):
        for c in range(C50+1):
            if X == 500*a + 100*b + 50*c:
                out = out+1

print(out)

Measured memory_bytes: 39664
let read f = stdin.ReadLine() |> f
let reads f =  stdin.ReadLine().Split() |> Array.map f

let _ = read int
let hs = reads int |> Array.toList
let f xs =
    let rec loop xs acc m =
        match xs with
        | [] -> m
        | [_] -> m
        | y::ys when y >= ys.Head -> loop ys (acc+1) (max m (acc+1))
        | y::ys -> loop ys 0 m
    loop xs 0 0

printfn "%d" (f hs)

Measured memory_bytes: 33368
#include<bits/stdc++.h>
#define inf 1e15
using namespace std;

typedef long long ll;

int main()
{
  ll a,b,n,ans=inf;

  cin>>a>>b>>n;

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(b%j==0){
      ans=min(ans,abs(a-(b*i)/j));
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n-1);
    int ans=0;

    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
        ans+=b[i];
    }
    rep(i,n-1){
        cin>>c[i];
    }

    rep(i,n){
        if(a[i+1]-1==a[i]){
            ans+=c[a[i]-1];
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
# import itertools
# r = list(range(4))
# for indices in itertools.permutations(r):
#     print(list(indices))
# exit()


N, M, R = map(int, input().split(' '))
r = [int(c) - 1 for c in input().split(' ')]

INF = float("inf")
table = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    table[i][i] = 0

for _ in range(M):
    a, b, c = map(int, input().split(' '))
    a -= 1
    b -= 1
    table[a][b] = c
    table[b][a] = c

#
for k in range(N):
    for i in range(N):
        for j in range(N):
            table[i][j] = min(table[i][j], table[i][k] + table[k][j])

# print(table)
import itertools
ans = INF
len_r = len(r)
for indices in itertools.permutations(r):
    indices = list(indices)
    ans = min(ans, sum([table[indices[i]][indices[i+1]] for i in range(len_r-1)]))

print(ans)

Measured memory_bytes: 73304
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >>s;
    int ans = INF;
    rep(i,(int)s.size()-2)cmin(ans, abs(stoi(s.substr(i,3)) - 753));
    cout << ans << endl;
}




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

{
    int n;
    cin>>n;
    n%=10;
    if (n==6 or n==0 or n==1 or n==8)
    {
        cout<<"pon";
    }
    else if (n==3)
    {
        cout<<"bon";
    }
    else
    {
        cout<<"hon";
    }
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0), B(N + 1, 0), C(N + 1, 0), S(N + 1, 0), lS(N + 1, 0);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    for(int j = 0; j <= N; j++) {
        C[B[j]]++;
    }
    for(int k = 0; k <= N; k++) {
        S[k] += C[k];
        lS[k] += k * C[k];
        if(k) {
            S[k] += S[k - 1];
            lS[k] += lS[k - 1];
        }
    }
    vector<int> X_K(N + 1), ans(N);
    X_K[0] = N;
    for(int X = 1; X <= N; X++) {
        X_K[X] = (lS[X] + X * (S[N] - S[X])) / X;
    }
    int x = N;
    for(int K = 1; K <= N; K++) {
        while(K > X_K[x]) x--;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 9088
n=io.read("*n","*l")
a={0}
for i=1,n do
    a[i]=io.read("*n")
end

b={a[1]}
for i=2,n do
    b[i]=b[i-1]+a[i]
end
c={b[n]}
for i=2,n do
    c[i]=c[i-1]-a[i-1]
end

minyen=2020202020
for i=1,n-1 do
    minyen=math.min(minyen,math.abs(b[i]-c[i+1]))
end
print(minyen)

Measured memory_bytes: 12664
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5+1;
ll f, s[N], a;
lll x, y;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  f = 1;
  FOR(i, 1, n+1){
    f = f * i % mod;
    gcd(lll(i), lll(mod), x, y);
    s[i] = (ll(x) % mod + mod + s[i-1]) % mod;
  }
  ll ans = 0;
  FOR(i, 0, n){
    cin >> a;
    ans += (s[i+1]+s[n-i]+mod-1) * a % mod;
  }
  cout << ans % mod * f % mod << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int n;
  cin>>n;
  vector<int> p(n),s(3),t(3);
  r(i,n){
    cin>>p.at(i);
  }
  int cnt=0;
  for(int i=1;i<n-1;i++){
      s.at(0)=p.at(i-1);
      s.at(1)=p.at(i);
      s.at(2)=p.at(i+1);
      t=s;
      sort(s.begin(),s.end());
      if(t.at(1)==s.at(1))cnt++;
  }

  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#n,m
n,m = (int(x) for x in input().split())

#a
a = list(map(int, input().split()))

a.sort(reverse=True)

sum = 0
for i in a:
    sum += i

#print(str(a[m-1]),str(sum),str(1 / (4 * m)))

if a[m-1]/sum >= 1 / (4 * m):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long LL;
int main(){
	LL n,x,m,a[100005],sum=0,cnt;
	cin >> n;
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		}
	cin >> m;
	for(int i = 1;i <= m;i++){
		cin >> cnt >> x;
		cout << sum - a[cnt] + x << endl;
		}
	return 0;
	}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int t,n;
int hate[10];

bool check(int m){
	while(m>0){
		if(hate[m%10])
			return false;
		m/=10;
		}
		return true;
	}
int main()
{
	cin>>n>>t;
	for(int i=0;i<t;++i){
		int x;
		cin>>x;
		hate[x]=1;
		}
		while(!check(n)){
			++n;
			}
		cout<<n;
		return 0;
	}

Measured memory_bytes: 256
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defmacro split-and-bind (arg-lst string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str-evaled (gensym "STR")))
    (labels ((expand (arg-lst &optional (init-pos1 t))
	       (if (null arg-lst)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str-evaled :start ,pos1 :test #'char=))
			    (,(car arg-lst) (parse-integer ,str-evaled :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr arg-lst) nil))))))
      `(let ((,str-evaled ,string))
	 ,@(expand arg-lst)))))

(deftype unum () '(integer 0 1000000000))
(defun main ()
  (declare #.O3)
  (let* ((n (the unum (read)))
	 (init-hp (read))
	 (max-a 0)
	 (lst-b nil))
    (dotimes (idx n)
      (split-and-bind (a b) (the string (read-line))
	(declare (unum a b))
	(when (>= a max-a) (setf max-a a))
	(push b lst-b)))
    (let* ((lst-b (sort lst-b #'>)))
      (print-line
       (loop with hp of-type fixnum = init-hp
	  with b-throw of-type unum = 0
	  for b of-type unum in lst-b
	  until (> max-a b)
	  do (incf b-throw)
	    (decf hp b)
	  until (<= hp 0)
	  finally (return (+ b-throw
			     (ceiling (max hp 0) max-a))))))))

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(with-open-file (out *dat-path*
		     :direction :output :if-exists :supersede)
  )

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 49640
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    vector<ll> q;
    vector<ll> m(200000,0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]==1) q.push_back(a[i]);
    }
    ll sum = 0;
    ll j = 0;
    while(q[j]!=0){
        sum += ((m[q[j]]-1)*m[q[j]])/2;
        j++;
    }
    rep(i,n){
        cout << sum - (m[a[i]]-1) << endl;
    }
}

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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;

    cin >> s;

    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[2] - '0') * 10 + (s[3] - '0');

    if(a == 0 && b == 0) cout << "NA" << endl;
    else if(a > 12 && b < 13 && b > 0) cout << "YYMM" << endl;
    else if(b > 12 && a < 13 && a > 0) cout << "MMYY" << endl;
    else if(a < 13 && b < 13) {
        if(a == 0) cout << "YYMM" << endl;
        else if(b == 0) cout << "MMYY" << endl;
        else cout << "AMBIGUOUS" << endl;
    }
    else cout << "NA" << endl;
}

/**
*/


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	A, B = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	if A <= 5:
		print(0)
	elif A <= 12:
		print(B // 2)
	else:
		print(B)

if __name__ == "__main__":
	main()

Measured memory_bytes: 3444
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, K = il()
    R = range(A, B + 1)
    for i in sorted(set(R[:K]) | set(R[-K:])):
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class T> 
ostream& operator<<(ostream &os, vector<T> input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, unordered_map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 100005;
const int INF = 1e9;
const int MOD = 1e9 + 7;

class TaskA {
private:

public:
	void solveOne(int it){
		int k;
		cin >> k;
		vector<string> ans(k, "ACL");
		for(string e : ans) {
			cout << e ;
		}
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3604
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String s = sc.next();
                sc.close();
                for(int i = 0 ; i < s.length() ; i++){
                        if(i % 2 == 0){
                                System.out.print(s.charAt(i));
                        }
                }
                System.out.println();
        }
}//0=48
//鶏になれ

Measured memory_bytes: 47092