akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int, input().split()))
v = [0] * n
v[1] = abs(h[1] - h[0])
for i in range(2, n):
    v[i] = min(abs(h[i] - h[i - 1]) + v[i - 1], abs(h[i] - h[i - 2]) + v[i - 2])
print(v[n - 1])


Measured memory_bytes: 13928
# from collections import deque

# n,q = map(int,input().split())
# c = [[] for i in range(n)]
# for i in range(n-1):
#     a,b = map(int,input().split())
#     c[a-1].append(b-1)
# px = deque([int(i) for i in input().split()] for j in range(q))
# que = deque()
# ans = [0 for i in range(n)]
# while px:
#     l = px.popleft()
#     x = l[1]
#     que.append(l[0]-1)
#     while que:
#         p = que.popleft()
#         ans[p] += x
#         for j in c[p]:
#             que.append(j)
# for i in range(n):
#     print(ans[i])

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N,Q = map(int,readline().split())
AB = [tuple(int(x) for x in readline().split()) for _ in range(N-1)]
PX = [tuple(int(x) for x in readline().split()) for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

par = [None] * (N+1)
q = [1]
while q:
    x = q.pop()
    for y in graph[x]:
        if y == par[x]:
            continue
        value[y] += value[x]
        q.append(y)
        par[y] = x

ans = ' '.join(map(str,value[1:]))
print(ans)

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	ll n;
	scanf("%lld", &n);
	ll cnt = 0;
	for (ll k=2 ; k<=min(n, 1000000LL) ; k++) {
		ll m = n;
		while (m%k == 0) m/=k;
		if (m%k == 1) cnt++;
	}
	if (n > 1000000LL) cnt++;
	n--;
	for (ll i=1 ; i*i<=n ; i++) {
		if (n%i == 0) {
			if (n/i > 1000000LL) cnt++;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) {
    cin >> p[i];
  }

  cout << accumulate(p.begin(), p.end(), 0) - *max_element(p.begin(), p.end()) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
ll a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	if (k&1) cout<<b-a;else cout<<a-b;
}

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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

  int root(int x){ //データxが属する木の根を再帰で得る : root(x) = {xの木の根}
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

  bool same(int x, int y){//2つのデータx，yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

ll calc(ll A){

  ll count = (A + 1) / 2;
  ll ans = count % 2;
  if (A % 2 == 0) ans ^= A;
  
  return ans;
}

int main(){

  ll A, B; cin >> A >> B;
  ll ans = calc(B) ^ calc(A - 1);
  pr(ans);

 return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main{
    
    
        
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        int s=sc.nextInt();
        int result=0;
        result=t*s;
        System.out.println(result);
        
    }
}

Measured memory_bytes: 35720
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class CBtree
{
public:
  vector<int> a;
  int solve();
};

int CBtree::solve()
{
  int n, x;
  cin >> n;

  a.push_back( 0 );
  
  for ( auto i = 0; i < n; ++i )
    {
      cin >> x;
      a.push_back( x );
    }

  for ( auto i = 1; i <= n; ++i )
    {
      cout << "node " << i << ": ";
      cout << "key = " << a[i] << ", ";
      if ( i / 2 > 0 )
        cout << "parent key = " << a[i/2] << ", ";
      if ( i * 2 <= n )
        cout << "left key = " << a[i * 2] << ", ";
      if ( i * 2 + 1 <= n )
        cout << "right key = " << a[i * 2 + 1] << ", ";
      cout << endl;
    }
  
  return 0;
}

int main()
{
  CBtree c;

  c.solve();

  return 0;
}

Measured memory_bytes: 1220
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    List<int> numList = new List<int>();
    bool answer = true;
    int maxNum;
    for(int i = 0; i < n; i++)
    {
      numList.Add(nums[i]);
    }
    numList.Sort();
    maxNum = numList[n-1];
    if(numList[n-2] != maxNum) answer = false;
    numList.RemoveAt(n-1);
    numList.RemoveAt(n-2);

    if(maxNum % 2 == 0)
    {
      for(int i = maxNum-1; i > maxNum/2; i--)
      {
        if(!numList.Contains(i)) answer = false;
        else numList.Remove(i);

        if(!numList.Contains(i)) answer = false;
        else numList.Remove(i);
      }
      if(!numList.Contains(maxNum/2)) answer = false;
      else numList.Remove(maxNum/2);

      while(numList.Count() > 0)
      {
        //Console.WriteLine(numList[0]);
        if(numList[0] <= maxNum/2)
        {
          answer = false;
          break;
        }
        else numList.RemoveAt(0);
      }
    }
    else
    {
      for(int i = maxNum-1; i > maxNum/2; i--)
      {
        if(!numList.Contains(i)) answer = false;
        else numList.Remove(i);

        if(!numList.Contains(i)) answer = false;
        else numList.Remove(i);
      }

      while(numList.Count() > 0)
      {
        if(numList[0] <= maxNum/2+1)
        {
          answer = false;
          break;
        }
        else numList.RemoveAt(0);
      }
    }
    
		Console.WriteLine(answer?"Possible":"Impossible");
	}
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    ll d,n; cin >> d >> n;
    int x = 0;
    if(d == 0) x = 1;
    if(d == 1) x = 100;
    if(d == 2) x = 10000;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += x;
    }
    if(n == 100) ans += x;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N, K;
        String S;
        
        Scanner scanner = new Scanner(System.in);
        N = Integer.valueOf(scanner.nextLine());
        S = scanner.nextLine();
        K = Integer.valueOf(scanner.nextLine()) - 1;
        scanner.close();
        
        char[] c = S.toCharArray();
        char targetChar = c[K];

        for (int i = 0; i < N; i++) {
            if (c[i] != targetChar ) {
                c[i] = '*';
            }
        }

        System.out.println(String.valueOf(c));
    }
    
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  
  for(int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  
  for(int i = 0; i < N; i++){
    if(V.at(i)-C.at(i) > 0){
      sum += V.at(i) - C.at(i);
    }
  }
 
  cout << sum <<endl;
}    

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

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

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

int main()
{
    int n;
    cin >> n;
    vector<pair<pint, bool>> p, q;
    int ans = 0;
    REP(i, n)
    {
        int a, b;
        cin >> a >> b;
        p.push_back(make_pair(make_pair(a, b), false));
    }
    REP(i, n)
    {
        int a, b;
        cin >> a >> b;
        q.push_back(make_pair(make_pair(a, b), false));
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    for (int i = p.size() - 1; i >= 0; i--)
    {
        int ymin = INF;
        int index = -1;
        for (int j = 0; j < n; j++)
        {
            if (p[i].first.first < q[j].first.first && p[i].first.second < q[j].first.second && q[j].second == false)
            {
                if (ymin > q[j].first.second)
                {
                    ymin = q[j].first.second;
                    index = j;
                }
            }
        }
        if (index != -1)
        {
            ans++;
            q[index].second = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

ll cutter[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288};

bool cut(int in, ll index){
    if(in/cutter[index]%2==0) return false;
    else return true;
}

int main(void){
    ll N;
    unordered_map<string, ll> kosuL;
    unordered_map<string, ll> kosuR;
    ll count=0;
    string S;
    cin>>N>>S;
    string SL="", SR="";
    rep(i, N){
        SL+=S[i];
        SR+=S[2*N-1-i];
    }
    ll ZENTAN_MAX=pow(2, N);
    rep(i, ZENTAN_MAX){
        string str="", str2="";
        rep(j, N) if(cut(i, j)) str+=SL[j]; else str2+=SL[j];
        //cout<<str<<sp<<str2<<endl;
        string ansstr=str+"#"+str2;
        kosuL[ansstr]++;
    }
    rep(i, ZENTAN_MAX){
        string str="", str2="";
        rep(j, N) if(cut(i, j)) str+=SR[j]; else str2+=SR[j];
        //cout<<str<<sp<<str2<<endl;
        string ansstr=str+"#"+str2;
        kosuR[ansstr]++;
    }
    for(auto itr : kosuR){
        count+=(itr.second)*kosuL[itr.first];
    }
    cout<<count<<endl;
    return 0;
}


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

main() {
  int N, P; cin >> N >> P;
  bool odd = false;
  rep(i, N) {
    int A; cin >> A;
    if (A % 2 != 0) odd = true;
  }
  ll ans;
  if (odd) {
    ans = 1;
    rep(i, N - 1) ans *= 2;
  } else {
    if (P == 0) {
      ans = 1;
      rep(i, N) ans *= 2;
    } else {
      ans = 0;
    }
  }
  cout << ans << endl;
}

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


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        if(i%3 != 0 && i%5 != 0)ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
A = LI()

def r_increment(r, x, y):
    return r+1, x^A[r], y+A[r]  # x は [l,r)

def l_increment(l, x, y):
    return l+1, x^A[l], y-A[l]  # x は [l,r)

def check(x, y):
    return x == y

ans = 0
r = 0
x = 0
y = 0
for l in range(n):
    while r < n and check(x^A[r], y+A[r]):
        r, x, y = r_increment(r, x, y)

    # l==rでなければ、[l,r)は条件を満たす (要素が一つの場合も条件を満たす)
    # ans処理
    if not l == r:
        ans += r-l

    if l < r:
        _, x, y = l_increment(l, x, y)
    else:
        _, x, y = l_increment(l, x, y)
        r, x, y = r_increment(r, x, y)

print(ans)


Measured memory_bytes: 97772
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

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

    vector<int> a[2];
    for (int g = 0; g < 2; g++) {
        a[g].resize(n);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[0][i]);
        a[1][n - i - 1] = a[0][i];
    }

    // 最初のj個を使ったときに和をiにできるか
    vector<char[5000]> dp[2];
    for (int g = 0; g < 2; g++) {
        dp[g] = vector<char[5000]>(n);
        dp[g][0][0] = 1;
        for (int j = 0; j < n - 1; j++) {
            memcpy(dp[g][j + 1], dp[g][j], sizeof dp[g][0]);
            for (int i = k - a[g][j] - 1; i >= 0; i--) {
                if (dp[g][j][i]) dp[g][j + 1][i + a[g][j]] = 1;
            }
        }
    }

    int r = n;
    for (int j = 0; j < n; j++) {
        int t = k; // どこまでチェックしたか
        for (int i = 0; i < k; i++) {
            if (!dp[0][j][i]) continue;
            int h0 = max(k - i - a[0][j], 0);
            int h1 = min(k - i, t);
            t = min(t, h0);
            for (int h = h0; h < h1; h++) {
                if (dp[1][n - j - 1][h]) { r--; i = k; break; }
            }
        }
    }
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 49152
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {}
void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void qsortv(vector<T>& v) { qsort(v.data(), v.size(), sizeof(T), [](const void*a, const void*b)->int {if ((*(T*)a) < (*(T*)b))return -1; if ((*(T*)a) == (*(T*)b))return 0; return 1; }); }
template <typename T, typename F>inline void qsortv(vector<T>& v, F func) { qsort(v.data(), v.size(), sizeof(T), func); }
template <typename T>inline void sortv(vector<T>& v) { sort(v.begin(), v.end()); }
// ==================================================

int main()
{
	din(int, n);

	dout(n % 111 ? (n / 100 * 111 > n ? n / 100 * 111 : (n / 100 + 1) * 111) : n);
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void yes() { cout << "YES" << endl; }
void no() { cout << "NO" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

void solve(string s1, string s2) {
  bool result =
      s1.at(0) == s2.at(2) && s1.at(1) == s2.at(1) && s1.at(2) == s2.at(0);
  yesOrNo(result);
}

int main() {
  string s1, s2;
  cin >> s1;
  cin >> s2;
  solve(s1, s2);
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s;
  cin>>s;
  int n = s.size();
  ll wc=0;
  ll ans=0;
  revrep(i,n) {
    if(s[i]=='W') wc++;
    else ans+=wc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include <cstdio>

int main() {
  bool first = true;
  while (true) {
    int p;
    scanf("%d", &p);
    if (p == 0) break;
    int n10, n50, n100, n500;
    scanf("%d %d %d %d", &n10, &n50, &n100, &n500);
    int rest = n10*10+n50*50+n100*100+n500*500-p;
    n500 -= rest/500;
    rest %= 500;
    n100 -= rest/100;
    rest %= 100;
    n50 -= rest/50;
    rest %= 50;
    n10 -= rest/10;
    if (!first) putchar('\n');
    first = false;
    if (n10 > 0) printf("%d %d\n", 10, n10);
    if (n50 > 0) printf("%d %d\n", 50, n50);
    if (n100 > 0) printf("%d %d\n", 100, n100);
    if (n500 > 0) printf("%d %d\n", 500, n500);
  }
  return 0;
}

Measured memory_bytes: 2596
#include <stdio.h>

int main() {

    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if (a < b) {

      if (b < c) printf("Yes\n");
      else       printf("No\n");

    }else{
        printf("No\n"); 
    }

    return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int[] n=new int[3];
    n[0]=sc.nextInt();
    n[1]=sc.nextInt();
    n[2]=sc.nextInt();
    Arrays.sort(n);
    if(n[0]+n[1]==n[2]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21588
import java.util.*;

public class Main {
    public static void main(String []args) throws Exception {
    	Main o = new Main();
        o.run();
    }

	void run() throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char []chars = s.toCharArray();
		int len = chars.length / 2;
		while (len > 0) {
			len--;
			if (match(chars, len)) {
				System.out.println(len * 2);
				return;
			}
		}
	}

	boolean match(char[]chars, int off) {
		int last = off * 2;
		for (int i = 0; i < off; i++) {
			char c1 = chars[i];
			char c2 = chars[i + off];
			if (c1 != c2) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
 
int main(){
	int W,H,N;
	cin>>W>>H>>N;
	bool rec[101][101]={};
	for(int i=0;i<N;i++){
		int x,y,a;
		cin>>x>>y>>a;
		switch(a){
			case 1:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(k<=x)
						rec[j][k]=1;
				break;
			case 2:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(k>x)
						rec[j][k]=1;
				break;
			case 3:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(j<=y)
						rec[j][k]=1;
				break;
			case 4:
				for(int j=1;j<=H;j++)for(int k=1;k<=W;k++)
					if(j>y)
						rec[j][k]=1;
				break;
		}
	}
	int ans=0;
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
		if(!rec[i][j])
			ans++;
	cout<<ans<<endl;
	/*
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cout<<rec[i][j];
		}
		cout<<endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 256
import math

n=int(input())
x=list(map(float,input().split(" ")))
y=list(map(float,input().split(" ")))

#p=1
print(sum(list(map(lambda x,y:abs(x-y),x,y))))
#p=2
print(math.sqrt(sum(list(map(lambda x,y:(x-y)**2,x,y)))))
#p=3
print(math.pow(sum(list(map(lambda x,y:abs(x-y)**3,x,y))),1/3))
#p=∞
print(max(list(map(lambda x,y:abs(x-y),x,y))))


Measured memory_bytes: 5712
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> friend_list[100001], ng_list[100001];
int component_size[100001];
int group_num[100001];

void dfs(int v, int c)
{
    group_num[v] = c;
    component_size[c]++;

    for (int i = 0; i < friend_list[v].size(); i++) {
        if (!group_num[friend_list[v][i]]) {
            dfs(friend_list[v][i], c);
        }
    }
}

int main()
{
    int N, M, K;

    scanf("%d %d %d", &N, &M, &K);

    for (int i = 0; i < M; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        friend_list[x].push_back(y);
        friend_list[y].push_back(x);
    }

    for (int i = 0; i < K; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        ng_list[x].push_back(y);
        ng_list[y].push_back(x);
    }

    int id = 1;

    for (int i = 0; i < N; i++) {
        if (!group_num[i]) dfs(i, id++);
    }

    for (int i = 0; i < N; i++) {
        int cnt = component_size[group_num[i]] - 1;
        for (int j = 0; j < friend_list[i].size(); j++) {
            if (group_num[friend_list[i][j]] == group_num[i]) cnt--;
        }

        for (int j = 0; j < ng_list[i].size(); j++) {
            if (group_num[ng_list[i][j]] == group_num[i]) cnt--;
        }

        printf("%d%c", cnt, " \n"[i + 1 == N]);
    }

    return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    if(s[0] == t[0])ans++;
    if(s[1] == t[1])ans++;
    if(s[2] == t[2])ans++;
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
    
    while(true){
        int n; cin>>n;
        if(n==0)break;
        vector<int> a(n);
        REP(i,n)cin>>a[i];
        sort(a.begin(),a.end());
        int ans = 1e9;
        REP(i,n-1)ans= min(ans,abs(a[i]-a[i+1]));
        cout<<ans<<endl;
    }
    
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    cout << A / g * B << endl;

    return 0;
}

Measured memory_bytes: 256
/*
2020-04-26
atcoder ABC
C - gacha
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    set<string> S;
    for(int i = 0; i < N; i++) {
        string input_s;
        cin >> input_s;
        S.insert(input_s);
    }
    cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 19224
s = input()
N = len(s)

def solve():
    l = 0
    r = N - 1
    cost = 0
    while l < r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == 'x':
            cost += 1
            l += 1
        elif s[r] == 'x':
            cost += 1
            r -= 1
        else:
            return -1
    return cost

print(solve())


Measured memory_bytes: 3316
def can_view(s):
  t = s[-1]
  for h in s[:-1]:
    if h > t:
      return False
  return True

c = int(input())
hs = list(map(int, input().split(" ")))
a = 0
for i in range(c):
  if can_view(hs[:i+1]):
    a+=1
print(a)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  ll a,b,c;cin>>a>>b>>c;
  if(b==c){
      cout<<"YES"<<endl;
      return 0;
  }
  repi(i,1,100){
    ll tmp=(a*i)%b;
    if(tmp==c){
     cout<<"YES"<<endl;
      return 0;
    }
    if(a*i>100000000000000000)break;
  }
  cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main() {
 
 
  int   a,b,c  ;
  
 
 
 scanf("%d%d%d",&a,&b,&c);
 int x;
 if(a==c)
 x=b;
 if(b==c)
 x=a;
 if(a==b)
 x=c;
 int ans=x;
 printf("%d\n",ans);

  return 0;

}

Measured memory_bytes: 128
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int num1 = sc.nextInt();
            int num2 = sc.nextInt();
            int num3 = sc.nextInt();
            if(num1 <= num3 && num3 <= num2){
              System.out.println("Yes");
            } else {
              System.out.println("No");
            }
          }
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, A[200000];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];

  auto check = [&](int size) {
    stack< pair< int, int > > st;
    if(A[0] != 1) st.emplace(1, 0);
    st.emplace(A[0], 0);

    for(int i = 1; i < N; i++) {
      bool erased = false;
      while(st.top().first > A[i]) {
        erased = true;
        st.pop();
      }
      int cur_pos = A[i];
      while(st.size() && (st.top().first == cur_pos && st.top().second + 1 >= size)) {
        erased = true;
        --cur_pos;
        st.pop();
      }
      if(st.empty()) {
        return false;
      } else if(st.top().first == cur_pos) {
        st.top().second++;
      } else if(erased) {
        st.emplace(cur_pos, 1);
        if(size == 1) return false;
      } else {
        st.emplace(cur_pos, 0);
      }
      ++cur_pos;
      if(cur_pos <= A[i]) {
        st.emplace(A[i], 0);
      }
    }
    return true;
  };

  int ok = N, ng = 0;
  while(ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}


Measured memory_bytes: 2720
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;

int n, m, d[N], tmp[N], fa[N];

struct Edge {
	int x, y, z;
	bool operator < (const Edge &T) const {
		return z < T.z;
	}
};

vector<Edge> E;

inline bool changed() {
	for (int i = 0; i < n; ++ i) 
		if (d[i] ^ tmp[i]) return true;
	for (int i = 0; i < n; ++ i) 
		E.push_back((Edge){i, (i + 1) % n, d[i]}), fa[i] = i;
	return false;
}

inline int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main() {
	//freopen("gkk.in", "r", stdin);
	//freopen("gkk.out", "w", stdout);

	memset(d, 0x3f, sizeof(d));
	scanf("%d%d", &n, &m);
	for (int x, y, z, i = 1; i <= m; ++ i) {
		scanf("%d%d%d", &x, &y, &z);
		d[x] = min(d[x], z + 1);
		d[y] = min(d[y], z + 2);
		E.push_back((Edge){x, y, z});
	}

	do {
		for (int i = 0; i < n; ++ i)
			tmp[i] = d[i];
		for (int i = 0; i < n; ++ i) 
			d[i] = min(d[i], d[(i + n - 1) % n] + 2);
	}while (changed());

	long long ans = 0;
	sort(E.begin(), E.end());
	for (int j = 0, sz = E.size(); j < sz; ++ j) {
		int u = find(E[j].x), v = find(E[j].y);
		if(u ^ v) ans += E[j].z, fa[u] = v;
	}
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 10224
n=int(input())
n-=1
a=list(map(int,input().split()))
cnt=0
ans=0
for i in range(n):
    if cnt>0:
        a[i]=a[i]*(-1)
    if a[i]<0:
        cnt=2
        a[i]=a[i]*(-1)
    else:
        pass
    ans+=a[i]
    cnt-=1
if cnt>0:
    a[n]=a[n]*(-1)
if a[n]<0:
    a[n]=a[n]*(-1)
    m=min(a)
    ans=ans+a[n]-m*2
else:
    ans+=a[n]
print(ans)


Measured memory_bytes: 14492
#include <stdio.h>


#define MAX 20001

struct pair {
    int x;
    int ar;
};

int top_stack1 = 0, top_stack2 = 0;


int stack1[MAX];
struct pair stack2[MAX];


void pushStack1(int x)
{

    stack1[top_stack1] = x;

    top_stack1 ++;

}

void pushStack2(int j, int a)
{

    stack2[top_stack2].x = j;

    stack2[top_stack2].ar = a;

    top_stack2 ++;
}

int popStack1(void)
{

    int r = 0;

    top_stack1--;

    if (top_stack1 < 0) {
        top_stack1 = 0;
        return 0;
    }

    r = stack1[top_stack1];

    return r;
}

struct pair popStack2(void)
{

    struct pair s;

    top_stack2--;

    if (top_stack2 < 0) {

        top_stack2 = 0;

        return;
    }

    s = stack2[top_stack2];

    return s;

}

int main()
{

    int i, j, sum = 0, a;

    struct pair c;

    char input[MAX];


    scanf("%s", input);


    for (i = 0; input[i] != '\0'; i ++) {
        if (input[i] == '\\') {
            pushStack1(i);
        } else if ((input[i] == '/') && (top_stack1 > 0)) {

            j = popStack1();

            sum += i - j;

            a = i - j;

            while (stack2[top_stack2 - 1].x > j) {

                a += stack2[top_stack2 - 1].ar ;

                c = popStack2();
            }
            pushStack2(j, a);
        }
    }


    printf("%d\n", sum);

    printf("%d", top_stack2);

    for (i = 0; i < top_stack2; i ++) {
        printf(" %d", stack2[i].ar);
    }
    printf("\n");


    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
int n,m;
int last[Maxn],pre[Maxn],other[Maxn],cnt=1;
int deg[Maxn];
bool vis[Maxn],flag[Maxn];
void insert(int u,int v)
{
    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
void dfs(int u,int fa)
{
    vis[u]=true;
    for (int q=last[u];q;q=pre[q])
    {
        if (flag[q]) continue;
        int v=other[q];
        if (v!=fa)
        {
            if (vis[v])
            {
                printf("%d %d\n",u,v);
                ++deg[u];
            } else dfs(v,u);
            flag[q]=true;
            flag[q^1]=true;
        }
    }
    if (deg[u]%2!=0)
    {
        printf("%d %d\n",u,fa);
        ++deg[u];
    } else if (u!=1)
    {
        printf("%d %d\n",fa,u);
        ++deg[fa];
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    if (m%2!=0)
    {
        printf("%d\n",-1);
        return 0;
    }
    for (int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        insert(u,v),insert(v,u);
    }
    dfs(1,-1);
    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int check(int x)
{
	int c=0;
	int flag=0;
	while(x>0)
	{
		int f= x%10;
		x=x/10;
		c++;
		if(f<2)
		{
			flag=1;
		}
	}
	if(flag==0 && c==2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int32_t main()
{
	IOS;
	int m,d;
	cin >> m >> d;
	int ans=0;
	rep(i,1,m)
	{
		rep(j,1,d)
		{
			if(check(j)==1)
			{
				int jj=j;
				int x=jj%10;
				jj=jj/10;
				int y= jj%10;
				if(x*y==i)
				{
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MAX  = 3234566667;

int main() {
  int k;
  cin >> k;
  if (k < 10) {
    P(k);
    return 0;
  }

  vector<ll> v;
  for (int i = 1; i < 10; i++) {
    v.push_back(i);
  }

  int count = 9;
  ll x = 0;
  while (x <= MAX) {
    vector<ll> v2 = v;
    v.clear();
    for (int i = 0; i < v2.size(); i++) {
      string tmp = to_string(v2[i]);
      int last = tmp[tmp.size() - 1] - '0';
      ll check = 0;
      if (last - 1 >= 0) {
        check = v2[i] * 10 + last - 1;
        count++;
        if (count == k) {
          P(check);
          return 0;
        }
        v.push_back(check);
      }
      check = v2[i] * 10 + last;
      count++;
      if (count == k) {
        P(check);
        return 0;
      }
      v.push_back(check);
      if (last + 1 < 10) {
        check = v2[i] * 10 + last + 1;
        count++;
        if (count == k) {
          P(check);
          return 0;
        }
        v.push_back(check);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1016
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  string a[3];
  rep (i, 3) {
    cin >> a[i];
  }
  printf("%c%c%c\n", a[0][0], a[1][0], a[2][0]);
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
char S[101010], Sn;
int i, j,ansa,ansb;
int main(){
    scanf("%s", S);
    for (i = 0; S[i];i++)
    {
        if(i%2==S[i]-'0'){
            ansa++;
        }else{
            ansb++;
        }
    }
    printf("%d", ansa < ansb ? ansa : ansb);

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main(void){
	int n,min,max;
	scanf("%d",&n);
	
	min=1000;
	max=0;
	
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(min>a[i])	min=a[i];
		if(max<a[i])	max=a[i];
	}
	printf("%d",max-min);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int w;
int h;
int x;
int y;
int r;

int main(void){
	
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	
	if(x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0){
			printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main()
{
    fastio();
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans = 0;
    if(k<=a) ans = k;
    else{
        ans = a;
        k-=a;
        if(k<=b) ;
        else{
            k-=b;
            ans -= k;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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

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

    int N;
    cin >> N;
    vector<int> H(N);
    REP(i, N) { cin >> H.at(i); }
    int ans = 0;
    int tmp = 0;
    REP(i, N - 1) {
        if (H[i] >= H[i + 1]) {
            tmp++;
        } else {
            chmax(ans, tmp);
            tmp = 0;
        }
    }
    chmax(ans, tmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
let a_s = Array.init (read_int ()) @@ fun _ -> Scanf.scanf " %d" (+) 0
let s = Array.fold_left (+) 0 a_s
let _ = Array.fold_left (fun (m, l) a -> min m @@ abs @@ 2 * l - s, l + a) (max_int, 0) a_s |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 6016
# set
n,m = gets.chomp.split(" ").map(&:to_i)
count_AC = 0
count_WA = 0
chk_arr = Array.new(n) { Array.new(3)}

0.upto(n - 1) do |i|
  # index
  chk_arr[i][0] = i + 1
  
  # flug
  chk_arr[i][1] = 0

  # temp_WA
  chk_arr[i][2] = 0
end

# main
0.upto(m - 1) do |i|
  num,result = gets.chomp.split(" ")
  num = num.to_i
  # print ("#{num},#{result}\n")
  next if chk_arr[num - 1][1] == 1
  chk_arr[num - 1][2] += 1 if result == "WA"
  # p chk_arr[num - 1][2]
  if result == "AC" then
    count_AC += 1
    count_WA += chk_arr[num - 1][2]
    chk_arr[num - 1][1] += 1
  end
end

print ("#{count_AC} #{count_WA}\n")

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


int main(){
	int N, L;
	cin >> N >> L;
	int result = 0, mini = 1e9, rem = 0;
	for(int i = 1 ; i <= N; i++){
		result += L + i - 1;
		if(abs(L + i - 1) < mini){
			rem = L + i - 1;
			mini = abs(L + i - 1);
		}
	}
	cout << result - rem << '\n';
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

    vint A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin>>K;
    cout<<A[K-1]<<endl;
    return 0;
}


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

int main(void){
  	int A,B,C;
  	cin >> A >> B >> C;
  
  	if(A+B+C == 17){
      	cout << "YES" << endl;
    } else {
      	cout << "NO" << endl;
    }
  
  	return 0;
}	

Measured memory_bytes: 256
_kx = input().split()
x = int(_kx[0])
k = int(_kx[1])

i_beg = k-(x-1)
i_end = k+(x-1)

str_ret = ''
for i in range(i_beg, i_end+1):
  if i >= -1000000 and i <= 1000000:
    str_ret += str(i) + ' '
print(str_ret.strip())

Measured memory_bytes: 3060
import copy
def main():
  global graph,vis,n
  n,m,*ab = map(int,open(0).read().split())
  ab = [(ab[i]-1,ab[i+1]-1) for i in range(0,len(ab),2)]
  master_graph = [[False]*n for _ in range(n)]
  for i,j in ab:
    master_graph[i][j] = True
    master_graph[j][i] = True
  ans = 0
  for i,j in ab:
    graph = copy.deepcopy(master_graph)
    graph[i][j] = False
    graph[j][i] = False
    vis = [False]*n
    dfs(0)
    if not(all(vis)):
      ans += 1
  print(ans)

def dfs(x):
  if not vis[x]:
    vis[x] = True
    for i in range(n):
      if graph[x][i]:
        dfs(i)

main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    int x,a,b;
    cin >> x >> a >> b;
    int n = b-a;
    if(n <= 0){
        cout << "delicious" << endl;
    }
    else if(n <= x){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, p[];
		n = sc.nextInt();
		p = new int[n];
		
		for(int i = 0; i < n; ++i)p[i] = sc.nextInt();
		sc.close();
		
		Arrays.sort(p);
		
		int sum = 0;
		
		for(int i : p)sum += i;
		
		sum -= p[n - 1];
		sum += p[n - 1] / 2;
		
		System.out.println(sum);
	}

}


Measured memory_bytes: 20820
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),k=in();
    cout<<static_cast<int>(floor(log(n)/log(k)))+1<<endl;
}


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

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

using namespace std;

typedef pair<int, int> P;

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

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

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

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

    int n, k;
    cin >> n >> k;

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

    int ans = k;
    stack<P> st;
    st.emplace(1, 0);
    while(not st.empty()){
        int v = st.top().first;
        int p = st.top().second;
        st.pop();

        int x = k - 2;
        int y = SZ(edge[v]) - 1;
        if(v == 1){
            x++;
            y++;
        }
        rep(i, y){
            ans *= x - i;
            ans %= MOD;
        }
        for(int u : edge[v]){
            if(u == p){
                continue;
            }
            st.emplace(u, v);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8052