akhauriyash/Code-Regression huggingface dataset:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 998244353

#############
# Main Code #
#############

#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################
#####ide_ele#####
ide_ele = 0
#################
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
    def query(self, l, r):
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N, K = getNM()
A = getArray(N)
ma = max(A)

# Aの部分列
# Bの隣り合う要素の絶対値がK以下

# NlogNまでいける
# セグ木？ dp?
# 全てにエッジを貼る必要はない？
# LIS?
# まあdp

# 数字iの最長はなんぼか
seg = SegTree([0] * (ma + 1), segfunc, ide_ele)
dp = [1] * N
for i in range(N):
    dp[i] = seg.query(max(0, A[i] - K), min(ma, A[i] + K) + 1) + 1
    seg.update(A[i], dp[i])
print(max(dp))

Measured memory_bytes: 163584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll>ch[27];
int main() {
	string s,t;
	cin>>s>>t;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'a';
		ch[now].push_back(i+1);
	}
	for(ll i=0;i<26;i++){
		ch[i].push_back(INF);
	}
//	cout << 0<<endl;
	ll sum=0;
	ll nex=0;
	for(ll i=0;i<t.size();i++){
		ll now=t[i]-'a';
		auto itr=upper_bound(ch[now].begin(),ch[now].end(),nex);
		if(*itr==INF){
			if(ch[now][0]==INF){
				cout << -1;
				return 0;
			}
			sum+=s.size()-1-nex+ch[now][0]+1;
			nex=ch[now][0];
		}
		else{
		sum+=*itr+1-nex-1;
		nex=*itr;
		}
//		cout << sum<<endl;
	}
	cout <<sum;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1724
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    over = x
    bellow = x
    while True:
        if not bellow in p:
            print(bellow)
            break
        if not over in p:
            print(over)
            break
        over += 1
        bellow -= 1

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

bool iskai(int n) {
	string s = to_string(n);
	string t = s; reverse(all(t));
	return s == t;
}

int main() {
    int a = ri();
	int b = ri();
	int res = 0;
	UPTO(i,a,b) if (iskai(i)) res++;
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_H = 50;
char s[MAX_H][MAX_H];
int H, W;

void solve() {
    REP(h, H) REP(w, W) {
            if (s[h][w] == '.') continue;
            if (s[max(h - 1, 0)][w] != '#' && s[min(h + 1, H - 1)][w] != '#' &&
                s[h][max(w - 1, 0)] != '#' && s[h][min(w + 1, W - 1)] != '#') {
                cout << "No" << endl;
                return;
            }
        }
    cout << "Yes" << endl;
}

int main() {
    cin >> H >> W;
    REP(h, H) REP(w, W) cin >> s[h][w];
    solve();
    return 0;
}

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

using namespace std;

int main() {
	int n,ans;
	string s,t;
	cin >> n >> s >> t;
	ans = n*2;

	for(int i = 0; i < n; i++){
		int chk = n-i;
		if(s.substr(i,chk) == t.substr(0,chk)){
			ans -= chk;
			break;
		}

	}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<LL> a(N+1, 0);
    REP(i, N){
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    REP(i, N+1) a[i] %= M;
    sort(all(a));
    LL now = 0, ct = 0;
    LL ans = 0;
    REP(i, N+1){
        if(i == N || now != a[i]){
            if(i == N && now == a[i]) ct++;
            now = a[i];
            ans += ct*(ct-1)/2;
            ct = 1;
        }else{
            ct++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

ll gcd(ll a, ll b){
    if(a<b){
      ll x;
      x = a;
      a = b;
    }
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
template <typename T>
T lcm(T x, T y) {
    return x / gcd(max(x,y), min(x,y)) * y;
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
 
int main()
{
    ll n;
    cin >> n;
    vector<int> v(n);

    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double cnt=2;
    double ans=v[0];
    rep(i,n-1){
        ans+=(v[i+1]);
        ans/=cnt;
    }
    cout << ans << endl;

  return 0;
}


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

int main() {
    string n;  cin >> n;

    if (n[0] == '9')  n[0] = '1';
    else if (n[0] == '1')  n[0] = '9';

    if (n[1] == '9')  n[1] = '1';
    else if (n[1] == '1')  n[1] = '9';

    if (n[2] == '9')  n[2] = '1';
    else if (n[2] == '1')  n[2] = '9';

    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e3 + 5, inf = 1e18, mod = 1e9 + 7;

int H, W, dp[N][N];
char mat[N][N];

bool inside(int x, int y){
    return x >= 1 && y >= 1 && x <= H && y <= W;
}

int go(int x, int y){
    if(!inside(x,y)) return 0;
    if(mat[x][y] == '#')    return 0;
    if(x == H && y == W)
        return 1;
    int &ans = dp[x][y];
    if(~ans)
        return ans;
    ans = 0;
    ans = (ans + go(x + 1, y)) % mod;
    ans = (ans + go(x, y + 1)) % mod;
    return ans;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  


    memset(dp, -1, sizeof(dp));
    cin >> H >> W;
    for(int i = 1; i <= H; i++)
        for(int j = 1; j <= W; j++)
            cin >> mat[i][j];
    cout << go(1,1);
}

Measured memory_bytes: 12584
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))

Measured memory_bytes: 8976
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] l = IntStream.of(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()).boxed().sorted(Comparator.reverseOrder()).mapToInt(Integer::new).toArray();
        for (int i = 0; i < l.length; i++) {
            System.out.print(i != l.length - 1 ? l[i] + " " : l[i] + "\n");
        }

    }
}


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

using namespace std;

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

  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    const int x = (a[i] == b[i]) + (b[i] == c[i]) + (c[i] == a[i]);
    if (x == 1 || x == 2) ans++;
    if (x == 0) ans += 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; i++)
	{
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void inssort(int A[], int N) {
	int j, i, v;
	for ( i = 1; i < N; i++)
	{
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];

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

	trace(A, N);
	inssort(A, N);

	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
ll ans=1,x;
ll cal(ll a,ll b){
	ll c=1;
	FOR(i,0,b){
		c*=a;
	}
	return c;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x;
	FOR(i,2,100){
		FOR(j,2,100){
			ll p=cal(i,j);
			if(p<=x&&ans<=p){
				ans=p;
			}else if(p>x)break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

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

bool solve(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b || d < b) return false;
    if (a > c){
        a -= (a - c + b - 1) / b * b;
    }
    if (a < 0) return false;
    ll x = d % b;
    if (x == 0) return true;
    ll p = gcd(b, x);
    // cout << a << " " << x << " " << p << endl;
    a += (c + p - a) / p * p;
    if (a < b) return false;
    return true;
}

int main() {
    int t;
    cin >> t;
    while (t--){
        bool f = solve();
        if (f) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
   // cout<<"Hello World!";
   int n;
   cin>>n;
   vector<int> v;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       v.push_back(x);
   }
   int sum=0;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           sum=sum+v[i]*v[j];
       }
   }
   cout<<sum<<endl;
}


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

class Cube {
   public:
    int f[6];  //サイコロ
    Cube() {}  //コンストラクタ
    void roll_z() { roll(1, 2, 4, 3); }
    void roll_y() { roll(0, 2, 5, 3); }  // to W
    void roll_x() { roll(0, 1, 5, 4); }  // to N
    void roll(int i, int j, int k, int l) {
        int t = f[i];
        f[i]  = f[j];
        f[j]  = f[k];
        f[k]  = f[l];
        f[l]  = t;
    }
    void move(char ch) {
        if (ch == 'E')
            for (int i = 0; i < 3; i++) roll_y();  // Wを３回
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S')
            for (int i = 0; i < 3; i++) roll_x();  // Nを３回
    }
};

int getRight(Cube c1, int top, int front) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (c1.f[0] == top && c1.f[1] == front) return c1.f[2];
            c1.roll_z();
        }
        if (i % 2 == 0)
            c1.roll_y();
        else
            c1.roll_x();
    }
    return -1;
}

int main() {
    Cube   c;    // サイコロ
    string com;  // 命令

    // 入力
    for (int i = 0; i < 6; i++) cin >> c.f[i];  // サイコロの面
    int q;
    cin >> q;  //質問回数

    int top, front, side;
    for (int i = 0; i < q; i++) {
        cin >> top >> front;
        cout << getRight(c, top, front) << endl;
    }
    return 0;
}


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

using namespace std;  

int main(){ 
    string s;
    cin >> s;

    if ((s[0] == s[1] && s[1] == s[2]) ||(s[2] == s[3] && s[1] == s[2] ))
        cout << "Yes" << endl;  
     else 
         cout << "No" << endl;  
    
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

const int N = 100010;

int a[N];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    
    n --, m --;
    int res = n / m;
    if(n % m)  res ++;
    printf("%d", res);
    return 0;
}

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

int main() {
  Int N,M;
  cin >> N >> M;
  
  Int s = 0;
  if (N >= 2) {
    s += N*(N-1)/2;
  }
  if (M >= 2) {
    s += M*(M-1)/2;
  }
  cout << s << endl;
  
  return 0;
}


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

const int mod = 1000000007;

int main(){
    char a, b;
    cin >> a >> b;
    int c = a - '0';
    int d = b - '0';
    string s="";
    if (c >= d)
    {
        rep(i, c)
        {
            s += b;
        }
    }else{
        rep(i,d){
            s += a;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<pair<ll, ll> >
#define vl vector<ll>
#define vi vector<int>
#define vii vector<pair<int, int> >
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
using namespace std;

ll power_mod(ll x, ll y, ll p)
{
	ll ans = 1;
	x = x%p;
	if(x==0)
	return p;

	while(y>0)
	{
		if(y&1)
		{
			ans = (ans*x)%p;
		}
		y = y>>1;
		x = (x*x)%p;
	}
	return ans;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll i,j,k,l,m,n;
	
	ll a,b,c;
	cin>>a>>b;
	cout<<6-a-b;
	return 0;
}


Measured memory_bytes: 3588
typedef int readtype;

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

typedef long long var;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}
/* }}} */

const int N = 2100005;
const long double Pi = acos(-1.0);

struct Node {
  int x, y;
};

int n, cnt;
int num[N << 1];
Node cir[N];
Node bnode, enode;

namespace TreeArray {
  int tree[N];
  void modify(int t, int v);
  int query(int t);
};

using namespace TreeArray;

int main() {
  bnode = (Node) {read(), read()}, enode = (Node) {read(), read()};
  if (bnode.y > enode.y) swap(bnode, enode);
  n = read();
  for (int i = 1; i <= n; ++i) {
    Node t = (Node) {read(), read()};
    if ((t.x < bnode.x && t.x < enode.x) ||
        (t.x > bnode.x && t.x > enode.x) || 
        (t.y < bnode.y && t.y < enode.y) || 
        (t.y > bnode.y && t.y > enode.y)) continue;
    cir[++cnt] = t;
  }
  n = cnt, cnt = 0;
  sort(cir + 1, cir + n + 1, [=] (Node a, Node b) { 
      return (bnode.x < enode.x) ^ (a.x > b.x);
      });
  for (int i = 1; i <= n; ++i) num[++cnt] = cir[i].y;
  sort(num + 1, num + cnt + 1);
  cnt = unique(num + 1, num + cnt + 1) - num - 1;
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    int k = upper_bound(num + 1, num + cnt + 1, cir[i].y) - num - 1, t = query(k) + 1;
    modify(k, t);
    res = max(res, t);
  }
  var xdist = abs(enode.x - bnode.x), ydist = abs(enode.y - bnode.y);
  long double dist = 100 * (xdist + ydist);
  dist += (var) res * (5 * Pi - 20);
  dist += (res > xdist || res > ydist) * 5 * Pi;
  printf("%.13Lf\n", dist);
  return 0;
}

namespace TreeArray {
  void modify(int t, int v) {
    for (int i = t; i <= cnt; i += i & -i) 
      tree[i] = max(tree[i], v);
  }
  int query(int t) {
    int res = 0;
    for (int i = t; i; i -= i & -i) 
      res = max(res, tree[i]);
    return res;
  }
}


Measured memory_bytes: 5248
import math

A,B,X = map(int,input().split())

fullBottle = A*A*B

if fullBottle >= X*2:
    C = 2*X/(A*B)
    ans = math.degrees(math.atan(C/B))
    print(90-ans)
else:
    C = 2*(B-X/(A**2))
    ans = math.degrees(math.atan(C/A))
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N; cin>>N;
  int S = 0;
  for (int i = 0; i < 1e6+1; i++)
  {
    S += i;
    if(N <= S)
    {
      cout<<i<<endl;
      return;
    }
  }
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


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

using namespace std;

const int N = 200010;
const int mod = (int) 1e9 + 7;

int fact[N], ifact[N];

int mul(int a, int b) {
  return (long long) a * b % mod;
}

vector<int> factorize(int n) {
  bitset<N> prime;
  prime.set();
  vector<int> primes;
  for (int i = 2; i < N; i++) {
    if (prime[i]) {
      primes.push_back(i);
      for (long long j = i * 1LL * i; j < N; j += i) {
        prime[j] = 0;
      }
    }
  }
  vector<int> ret;
  for (int i = 0; i < (int) primes.size() && primes[i] * 1LL * primes[i] <= n; i++) {
    int prime = primes[i];
    int counter = 0;
    while (n % prime == 0) {
      counter++;
      n /= prime;
    }
    if (counter > 0) {
      ret.push_back(counter);
    }
  }
  if (n > 1) {
    ret.push_back(1);
  }
  return ret;
}

int power(int x, int e) {
  int ret = 1;
  while (e > 0) {
    if (e & 1) {
      ret = mul(ret, x);
    }
    x = mul(x, x);
    e >>= 1;
  }
  return ret;
}

int inv(int x) {
  return power(x, mod - 2);
}

int comb(int n, int k) {
  int ret = fact[n];
  ret = mul(ret, ifact[n - k]);
  ret = mul(ret, ifact[k]);
  return ret;
}

int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  fact[0] = ifact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(i, fact[i - 1]);
    ifact[i] = mul(inv(i), ifact[i - 1]);
  }
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> factorization = factorize(m);
  int ans = 1;
  for (int p : factorization) {
    ans = mul(ans, comb(p + n - 1, n - 1));
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>

#define N 10000
#define Q 500

//???????????¢??°
int main(void){

  //??????????????°?????£?¨?
  int i,j,n,q,count=0,key,flag=0;;
  int s[N],t[Q];

 
  scanf("%d",&n);
  if(n>N) exit(1);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  
  scanf("%d",&q);
  if(q>Q) exit(2);
  for(i=0;i<q;i++) scanf("%d",&t[i]);

  //?????¢??¢?´¢????§?
  for(i=0;i<q;i++){
    flag=0;
    key=t[i];
      j=0;
    s[n]=key;

    while(1){
      if(s[j]==key){
	flag++;
	break;
      }
      j++;
      if(j==n) break;

    }
    if(flag==1) count ++;
  }


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

  return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    set<int> sunuke;
    for(int ix=0;ix<n;ix++){
        int d; cin >> d;
        for(int ix2=0;ix2<d;ix2++){
            int a; cin >> a;
            sunuke.insert(a);
        }
    }
    cout << (n-(int)sunuke.size()) << endl;
    
}

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

long long n;
vector<set<int>> g;
vector<vector<long long>> v;
vector<long long> a, cnt;

bool solve();

int main() {
  cin >> n;
  a.resize(n);
  g.resize(n);
  v.resize(n);
  cnt.assign(n, 0);
  for (auto& p : a) cin >> p;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[--x].insert(--y);
    g[y].insert(x);
    ++cnt[x];
    ++cnt[y];
  }
  if (solve())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

bool solve() {
  queue<long long> qu;
  for (int i = 0; i < n; ++i)
    if (cnt[i] == 1) qu.push(i);
  while (qu.size()) {
    int now = qu.front();
    qu.pop();
    long long sum = 0;
    for (auto p : v[now]) sum += p;
    sort(v[now].begin(), v[now].end(), greater<long long>());
    long long num = 0;
    if (v[now].size() > 1) {
      if (sum < a[now] || a[now] * 2 < sum || v[now][0] > a[now]) return 0;
      num = a[now] * 2 - sum;
    } else if (v[now].size() == 1) {
      if (sum != a[now]) return 0;
      num = a[now];
    } else
      num = a[now];
    if (cnt[now]) {
      int par = *g[now].begin();
      v[par].push_back(num);
      g[par].erase(now);
      if (--cnt[par] == 1) qu.push(par);
    } else {
      if (v[now].size() == 1)
        return a[now] == sum;
      else
        return a[now] * 2 == sum;
    }
  }
}

Measured memory_bytes: 21764
#include <cstdio>
#include <cstdlib>
int main (){
	int N, a[100], low = 1 << 30, total;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	for (int i = -100; i <= 100; i++){
		total = 0;
		for (int j = 0; j < N; j++)
			total += (a[j] - i) * (a[j] - i);
		if (low > total)
			low = total;
	}
	printf("%d\n", low);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
n = int(input())

ans = 0

keta = int(np.log10(n))
# print(keta)
for i in range(1, keta+1, 2):
    ans += 10**i - 10**(i-1)
    
if keta%2 == 0:
    ans += n - 10**keta + 1
print(ans)

Measured memory_bytes: 21392
l, r = map(int,input().split())


mod = 2019

ans = 0
if l//mod == r//mod: # !( l<= x*mod <= r)
    
    lm = min(l%mod,r%mod)
    rm = max(l%mod,r%mod)
    t = mod**2
    for i in range(lm,rm+1):
        for j in range(i+1,rm+1):
            t = min(i*j%mod,t)
    
    ans = t



print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int key(string s)
{
    if (s == "S")
    {
        return 0;
    }
    else if (s == "H")
    {
        return 1;
    }
    else if (s == "C")
    {
        return 2;
    }
    else if (s == "D")
    {
        return 3;
    }
}

int main()
{
    long long n;
    cin >> n;
    bool card[4][13] = {};

    for (int i = 0; i < n; i++)
    {
        string k;
        int a;
        cin >> k >> a;
        int num = key(k);
        card[num][a - 1] = true;
    }

    map<int, char> d;
    d[0] = 'S';
    d[1] = 'H';
    d[2] = 'C';
    d[3] = 'D';

    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            if (!card[i][j])
            {
                char k = d.at(i);
                cout << k << " " << j + 1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
int n, d, cnt[N][N];
int x[N * 100], y[N * 100];
int type[N][N];
int sum[N][N][2];
inline int S(int x, int y, int z) {
	if (x < 0 || y < 0) return 0;
	return sum[x][y][z];
}
bool check(int k) {
	++k;
	int x = k / d;
	ll t1 = (x + 1) * (x + 1ll);
	ll t2 = (x + 1ll) * x;
	ll t3 = (ll)x * x;
	for (int i = 0; i < d; ++i) {
		for (int j = 0; j < d; ++j) {
			if (cnt[i][j] <= t3) {
				type[i][j] = 2;
			} else 
			if (cnt[i][j] <= t2) {
				type[i][j] = 0;
			} else 
			if (cnt[i][j] <= t1) {
				type[i][j] = 1;
			} else {
				return 0;
			}
			//cout << type[i][j] << ",";
		} //cout << endl;
	}
	for (int i = 0; i < 2 * d; ++i) {
		for (int j = 0; j < 2 * d; ++j) {
			for (int k = 0; k < 2; ++k) {
				sum[i][j][k] = 0;
				if (i) sum[i][j][k] += sum[i - 1][j][k];
				if (j) sum[i][j][k] += sum[i][j - 1][k];
				if (i && j) sum[i][j][k] -= sum[i - 1][j - 1][k];
				if (k == type[i % d][j % d]) sum[i][j][k]++;
			}
		}
	}
	int tmp, tmp1, tmp2, p = k % d;
	for (int i = 0; i < d; ++i) {
		for (int j = 0; j < d; ++j) {
			tmp = S(i + p - 1, j + p - 1, 1) - S(i + p - 1, j - 1, 1) - S(i - 1, j + p - 1, 1) + S(i - 1, j - 1, 1);
			//cout << i << " " << j << " " << tmp << endl;
			if (sum[d - 1][d - 1][1] != tmp) continue;
			tmp1 = S(d - 1, j + p - 1, 0) - S(d - 1, j - 1, 0);
			tmp2 = S(i + p - 1, d - 1, 0) - S(i - 1, d - 1, 0);
			tmp = S(i + p - 1, j + p - 1, 0) - S(i + p - 1, j - 1, 0) - S(i - 1, j + p - 1, 0) + S(i - 1, j - 1, 0);
			if (tmp1 + tmp2 - tmp != sum[d - 1][d - 1][0]) continue;
			return 1;
		}
	}
	return 0;
}
int main() {
	scanf("%d %d", &n, &d);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", x + i, y + i);
		cnt[x[i] % d][y[i] % d]++;
	}
	//check(4);return 0;
	int l = 1, r = 1e6 + 5;
	while (l < r) {
		int mid = l + r >> 1;
		//cout << mid << endl;
		if (l + 1 == r) {
			if (check(l))
				--r;
			else
				++l;
			break;
		}
		if (check(mid))
			r = mid; 
		else 
			l = mid;
	}
	cout << l;
} 

Measured memory_bytes: 51456
#include<iostream>
#include<cstring>
using namespace std;
void combsort(long A[100010],int);

int main (){
  int N;
  long X;
  long A[100010];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  combsort(A,N);
  if (N%2==0)
  {
    X=0;
    for(int i=0;i<N/2-1;i++){
      X-=(A[i]*2);
    }
    for(int i=N/2+1;i<N;i++){
      X+=(A[i]*2);
    }
    X+=(A[N/2]);
    X-=(A[N/2-1]);
  }else{
    X=0;
    for(int i=0;i<N/2-1;i++){
      X-=(A[i]*2);
    }
    for(int i=N/2+2;i<N;i++){
      X+=(A[i]*2);
    }

    if (A[N/2+1]*2-A[N/2]-A[N/2-1]>A[N/2+1]+A[N/2]-A[N/2-1]*2)
    {
      X+=(A[N/2+1]*2-A[N/2]-A[N/2-1]);
    }else{
      X+=(A[N/2+1]+A[N/2]-A[N/2-1]*2);
    }
  }
  cout <<X <<endl;
}


void combsort(long A[100010],int N){
  int h=N*10/13;
  while (h>=1){
    int noswap=1;
    for (int i=0;i+h<N;i++){
      if (A[i]>A[i+h]){
        long a;
        a=A[i];A[i]=A[i+h];A[i+h]=a;
        noswap=0;
      }
    }
    if (h==1&&noswap){break;}
    h=h*10/13;
  }
}

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

public class Program
{
    public static void Main()
    {
        var nab = Console.ReadLine().Split()
            .Select(x => long.Parse(x))
            .ToArray();
        var n = (int)nab[0];
        var a = nab[1];
        var b = nab[2];
        var hs = Enumerable.Range(0, n)
            .Select(_ => long.Parse(Console.ReadLine()))
            .ToArray();

        var c = a - b;
        Func<long, bool> pred = xx => hs
            .Select(x => x - b * xx)
            .Where(x => x > 0)
            .Sum(x => (x - 1) / c + 1)
            <= xx;

        var minBound = 1L;
        var maxBound = (long)Math.Ceiling((double)hs.Max() / b);
        while (minBound != maxBound)
        {
            var t = (maxBound - minBound) / 2 + minBound;
            if (pred(t))
            {
                maxBound = t;
            }
            else
            {
                minBound = t + 1;
            }
        }
        
        Console.WriteLine(minBound);
    }
}


Measured memory_bytes: 19932
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define MOD 1000000007
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int N,K;

  N = inputValue();
  K = inputValue();

  ll ans = 0;
  ll nCr[N+1][N+1];
  int i,j;

  repd(i,0,N+1){
      nCr[i][0] = 1;
      nCr[i][i] = 1;
  }

  repd(i,1,N+1){
      repd(j,1,i+1){
          if(i == 0 || j == 0 || i == j){nCr[i][j] = 1;}
          else{
          nCr[i][j] = nCr[i-1][j-1] + nCr[i-1][j];
          nCr[i][j] %= MOD;
          }
      }
  }


  repd(i,1,K+1){
      if(N-K+1 < i){cout << 0 << endl; continue;}
      ans = nCr[K-1][i-1];
      ans *= nCr[N-K+1][i];
      ans %= MOD;
      cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5 + 77;
vector<int> g[MAXN];
int used[MAXN];
int n, m;

void solve() {
	cin >> n >> m;

	for(int i = 0; i < m; ++i) {
		int v = fetch<int>() - 1;
		int u = fetch<int>() - 1;

		g[v].push_back(u);
		g[u].push_back(v);
	}

	deque<int> answ;
	answ.push_back(0);
	used[0] = 1;

	for(;;) {
		int found = NIL;

		for(auto& v: g[answ.back()]) {
			if(!used[v]) {
				found = v;
				break;
			}
		}

		if(found == NIL) {
			break;
		}

		answ.push_back(found);
		used[found] = 1;
	}

	for(;;) {
		int found = NIL;

		for(auto& v: g[answ.front()]) {
			if(!used[v]) {
				found = v;
				break;
			}
		}

		if(found == NIL) {
			break;
		}

		answ.push_front(found);
		used[found] = 1;
	}

	cout << len(answ) << '\n';

	for(auto& elem: answ) {
		cout << elem + 1 << ' ';
	}

	cout << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2333;
struct pt{
    int x,y,nxt;
}s[maxn*2];
int fst[maxn];
int m,tn,n;
int k;
const int inf = 0x3f3f3f3f;
int uu;
void addedge(int x,int y){
    uu++;
    n++;
    s[n].x=x;s[n].y=y;
    s[n].nxt=fst[x];fst[x]=n;
}
int down,up;
int hasdown[maxn];
int hasup[maxn];
int totup[maxn];
int totdown[maxn];
int dep[maxn];

void dfs(int u,int fa){
    hasup[u]=hasdown[u]=0;
    if(dep[u]==up)hasup[u]=1;
    if(dep[u]==down)hasdown[u]=1;
    if(dep[u]<=up)totup[u]=1;
    if(dep[u]<=down)totdown[u]=1;
    if(dep[u]==up)
        return;
    for(int e=fst[u];e!=-1;e=s[e].nxt){
        int v=s[e].y;
        if(v!=fa){
            dep[v]=dep[u]+1;
            dfs(v,u);
            uu++;
            totup[u]+=totup[v];
            totdown[u]+=totdown[v];
            hasup[u]+=hasup[v];
            hasdown[u]+=hasdown[v];
        }
    }
}

int calc(int root){
    int tot = totdown[root];
    int maxc = 0;
    if(up!=down){
        for(int e=fst[root];e!=-1;e=s[e].nxt){
            int v=s[e].y;
            uu++;
            maxc=max(maxc,hasup[v]);
        }
        tot+=maxc;
    }
    return m-tot;
}



int main(){
    cin>>m>>k;int x,y;
    up=(k+1)/2;
    down=k/2;
    memset(fst,-1,sizeof(fst));
    for(int i=1;i<m;i++){
        cin>>x>>y;
        addedge(x,y);
        uu++;
        addedge(y,x);
    }
    int ans = inf;
    for(int i = 1;i<=m;i++){
        memset(totup,0,sizeof(totup));
        memset(totdown,0,sizeof(totdown));
        dep[i]=0;
        uu++;
        dfs(i,-1);
        ans=min(ans,calc(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e6+5;
const double eps = 1e-8;

string a,b,now;
int x,y;
int main(){
  cin>>a>>b;
  cin>>x>>y;
  cin>>now;
  if(now == a) x--;
  else y--;
  cout<<x<<" "<<y<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    val ans = setOf(1L, 2L, 3L) - A - B
    println(ans.first()!!)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



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

int main(void)
{
	int h, w;
	char c;
	int ans = 0;
	cin >> h >> w;
	vector<vector<int>> f(h, vector<int>(w, 0));

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> c;
			if (c == '.')
			{
				f[i][j] = 1;
			}
		}
	}

	vector<vector<int>> L(h, vector<int>(w, 0));
	vector<vector<int>> R(h, vector<int>(w, 0));
	vector<vector<int>> D(h, vector<int>(w, 0));
	vector<vector<int>> U(h, vector<int>(w, 0));

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (f[i][j] == 0)
			{
				L[i][j] = U[i][j] = 0;
			}
			else
			{
				if (j == 0)
				{
					L[i][j] = 1;
				}
				else
				{
					L[i][j] = L[i][j - 1] + 1;
				}
				if (i == 0)
				{
					U[i][j] = 1;
				}
				else
				{
					U[i][j] = U[i - 1][j] + 1;
				}
			}
		}
	}

	for (int i = h - 1; i >= 0; --i)
	{
		for (int j = w - 1; j >= 0; --j)
		{
			if (f[i][j] == 0)
			{
				R[i][j] = D[i][j] = 0;
			}
			else
			{
				if (j == w - 1)
				{
					R[i][j] = 1;
				}
				else
				{
					R[i][j] = R[i][j + 1] + 1;
				}
				if (i == h - 1)
				{
					D[i][j] = 1;
				}
				else
				{
					D[i][j] = D[i + 1][j] + 1;
				}
			}
		}
	}

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (f[i][j] != 0)
			{
				ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 78720
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
	t = input()
	if t == 'AC':
		ac += 1
	elif t == 'WA':
		wa += 1
	elif t == 'TLE':
		tle += 1
	else:
		re += 1
print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int a;

int main(){
  cin >> a;
  cout << 48 - a <<endl;
}

Measured memory_bytes: 256
list_original=input()
box=list(list_original)
MAX = 0
count = 0
flag = 0
for figure in box:
  if figure == 'A' or figure =='T' or figure =='C' or figure == 'G':
    flag = 1
  else:
    flag = 0
    count = 0
  if flag == 1:
    count += 1
  if count > MAX:
    MAX = count
print(MAX)

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


signed main(){
  int n,k;cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++)v[i]=(v[i]+k-1)%k;
  vector<int> w(n+1,0);
  for(int i=0;i<n;i++)w[i+1]=(v[i]+w[i])%k;
  map<int,int> m;
  int ans=0;
  for(int i=0;i<=n;i++){
    if(i>=k)m[w[i-k]]--;
    ans+=m[w[i]];
    m[w[i]]++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15872
open Batteries
(* charのlistをstringに *)
let string_of_chars chars = 
  let buf = Buffer.create 16 in
  List.iter (Buffer.add_char buf) chars;
  Buffer.contents buf
let _ = Scanf.sscanf (read_line()) "%s %s %s" (fun s1 s2 s3 ->
  [s1.[0]; s2.[0]; s3.[0]]
) |> string_of_chars |> String.uppercase_ascii |> print_endline

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
int ans;
char s[200005];
void Read() {
	int i;
	scanf("%s", s);
	int SIZ = strlen(s);
	for(i = 0; i < SIZ; i++) {
		ans += s[i] - '0';
		ans %= 9;
	}
	if(ans == 0)
		printf("Yes");
	else
		printf("No");
}
int main() {
	Read();
	return 0;
}

Measured memory_bytes: 1928
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	as := make([]int, n)
	gg := make([]int, n+1)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
		gg[i+1] = gcd(gg[i], as[i])
	}
	if gg[n] != 1 {
		fmt.Println("not coprime")
		return
	}

	dm := make(map[int]int)
	for i := 0; i < n; i++ {
		ps := primeFactorization(as[i])
		for p := range ps {
			dm[p]++
			if dm[p] > 1 {
				fmt.Println("setwise coprime")
				return
			}
		}
	}

	fmt.Println("pairwise coprime")
}

func primeFactorization(n int) map[int]int {
	ps := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			ps[i]++
			n /= i
		}
	}
	if n != 1 {
		ps[n]++
	}

	return ps
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

using namespace std;

void Main() {
    int A, B;
    cin >> A >> B;
    int ans = A + B;
    if (ans >= 24) {
        ans -= 24;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = new StringBuffer(sc.next()).reverse().toString();
        if(s1.equals(s2)) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 35812
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_d"
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func chmax(x *int, v int) {
	if *x < v {
		*x = v
	}
}

func solve(N, W int, wvs [][]int) int {
	t := make([][]int, N+1, N+1) // t[item_index][weight]
	for i := range t {
		t[i] = make([]int, W+1, W+1)
	}
	for i, wv := range wvs {
		w, v := wv[0], wv[1]
		for sumWeight := 0; sumWeight <= W; sumWeight++ {
			if wd := sumWeight - w; wd >= 0 {
				chmax(&t[i+1][sumWeight], t[i][wd]+v)
			}
			chmax(&t[i+1][sumWeight], t[i][sumWeight])
		}
	}
	return t[N][W]
}

func main() {
	scan := newScanner(os.Stdin)
	N, W := scan.Int(), scan.Int()
	wvs := make([][]int, N, N)
	for i := 0; i < N; i++ {
		wvs[i] = []int{scan.Int(), scan.Int()}
	}
	fmt.Println(solve(N, W, wvs))
}


Measured memory_bytes: 82588
n=int(input())
A=[int(_) for _ in input().split()]
B=[int(_) for _ in input().split()]
C=[int(_) for _ in input().split()]
ans=sum(B)
for i in range(n-1):
    if A[i+1]==A[i]+1:
        ans+=C[A[i]-1]

print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  int n,x,t;
  cin >> n >> x >> t;
  int c = n/x;
  if(n%x!=0)c++;
  cout << t*c << endl;
}

Measured memory_bytes: 3632
H, W = map(int, input().split())

memo = [[10**5]*W for _ in range(H)]
mp = [input() for _ in range(H)]

if mp[0][0] == '#':
  memo[0][0] = 1
else:
  memo[0][0] = 0

for i in range(H):
  for j in range(W):
    if i > 0:
      if mp[i-1][j] == '.' and mp[i][j] == '#':
        memo[i][j] = min(memo[i][j],memo[i-1][j]+1)
      else:
        memo[i][j] = min(memo[i][j],memo[i-1][j])
    if j > 0:
      if mp[i][j-1] == '.' and mp[i][j] == '#':
        memo[i][j] = min(memo[i][j],memo[i][j-1]+1)
      else:
        memo[i][j] = min(memo[i][j],memo[i][j-1])
        
print(memo[-1][-1])

Measured memory_bytes: 73892