akhauriyash/Code-Regression huggingface dataset:
#!/mnt/c/Users/moiki/bash/env/bin/python
N,K = map(int, input().split())
A = [ [int(j) for j in input().split()] for i in range(N)]
# I = [ [j for j in range(1,N+1) if Ai[j]] for Ai in A]
MOD = 10**9 + 7

# dp = [0] * (N+1)
dp = [ [0] * (N+1) for _ in range(N+1)]

S = [[1]*N]
KDIG = [0]*70

for i in range(1,61):
    if K % (1<<i) :
        KDIG[i-1] = 1
        K -= K%(1<<i)


def prod(A,B,k,l,m):#A:k*l,B:l*m
 
    C=[[None for i in range(m)] for j in range(k)]
 
    for i in range(k):
        for j in range(m):
            ANS=0
            for pl in range(l):
                ANS=(ANS+A[i][pl]*B[pl][j])%MOD
 
            C[i][j]=ANS
 
    return C



for i in range(60):
    if KDIG[i] == 1:
        S = prod(S,A,1,N,N)

    A = prod(A,A,N,N,N)
print(sum(S[0])%MOD)

# for i in range(1,N+1):
#     for j in range(1,N+1):
#         # dp[i][j] = np.linalg.matrix_power(A, K)[i-1][j-1].item()
#         # ans += dp[i][j] % MOD
#         # ans += np.linalg.matrix_power(A, K)[i-1][j-1].item() % MOD
#         # ans += M[i-1,j-1].item() % MOD
#         ans += M[i-1][j-1] % MOD

# print(ans%MOD)



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

int main() {
    int N;
    cin >> N;

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

    ll ans = 0, ans2 = 999999999;
    for(int i = 1; i <= 100; i++) {
        ans = 0;
        for(int j = 0; j < N; j++) {
            ans += pow((vs[j]-i), 2);
        }
        ans2 = min(ans, ans2);
    }
    cout << ans2 << '\n';

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    sort(ALL(s));
    sort(rALL(t));
    if(s<t){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

mod = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]


def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod


for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


for i in range(1, K + 1):
    print(cmb(N - K + 1, i) * cmb(K - 1, i - 1) % mod)

Measured memory_bytes: 42736
i=59,c=100,f[9],m,x,s;main(y){for(;s?++f[y*12+x+";<=0H/1GI:>T$"[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++i<178?i%12<10?m=fmax(m,f[i]),f[i]?c--:1:1:!printf("%d\n%d\n",c,m););}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll a,b,c;
string s;

int main() {
    cin>>a;
    if(a<1200){
        p("ABC");
    }else if(a<2800){
        p("ARC");
    }else{
        p("AGC");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int a, b;
  long int temp;
  cin >> a >> b;
  temp = a+b;
  if(temp %2 == 1)
    cout <<"IMPOSSIBLE"<<'\n';
  else
    cout << temp/2 << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

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

//10^9 + 7
const ll MOD = 1000000007;

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

	ll ans, add, even, tmp1, tmp2, tmp3, tmp4;
	tmp1 = (W + 1) / 2;
	tmp2 = (H + 1) / 2;
	add = tmp1 * tmp2;
	tmp3 = W / 2;
	tmp4 = H / 2;
	even = tmp3 * tmp4;
	ans = add + even;
	if (H == 1 || W == 1) ans = 1;
	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;

int main(){
  int y, m, d;
  char s;
  cin >> y >> s >> m >> s >> d;
  if (m<5) cout << "Heisei";
  else cout << "TBD";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int c[505][505], d[35][35];

int32_t main() {
    int n,m; cin >> n >> m;
    rep (i,m) rep (j,m) cin >> d[i][j];
    rep (i,n) rep (j,n) cin >> c[i][j], c[i][j]--;

    vector<pair<int,int> > cost[3];
    rep (r,3) rep (x,m) {
        int s = 0;
        rep (i,n) rep (j,n) if ((i+j)%3 == r) s += d[c[i][j]][x];
        cost[r].emplace_back(s,x);
    }
    rep (r,3) sort(all(cost[r]));

    int mi = 500*500*1000;
    rep (i,3) rep (j,3) rep (k,3) {
        cauto p = cost[0][i], q = cost[1][j], r = cost[2][k];
        if (p.snd != q.snd && q.snd != r.snd && r.snd != p.snd) {
            chmin(mi, p.fst + q.fst + r.fst);
        }
    }
    cout << mi << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  string s;
  cin >> s;
  if(s=="SUN"){
    cout << 7 << "\n";
  }
  else if(s=="MON"){
    cout << 6 << "\n";
  }
  else if(s=="TUE"){
    cout << 5 << "\n";
  }
  else if(s=="WED"){
    cout << 4 << "\n";
  }
  else if(s=="THU"){
    cout << 3 << "\n";
  }
  else if(s=="FRI"){
    cout << 2 << "\n";
  }
  else if(s=="SAT"){
    cout << 1 << "\n";
  }
}

Measured memory_bytes: 256
function main(arg) {
    arg = arg.split("\n")[0]
    arg = arg.split(" ")
    
    var a = Number(arg[0])
    var b = Number(arg[1])
    var k = Number(arg[2])
    
    for (var i = 0; i < k; i++) {
        if (i%2 === 0) {
            //takahashi
            if (a%2 === 1) {
                a--;
            }
            a /= 2
            b += a;
            
        } else {
            //aoki
            if (b%2 === 1) {
                b--;
            }
            b /= 2
            a += b;
        }
    }
    console.log(a +" "+ b)
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
import math
def fact(x):
  return math.factorial(x)
n, m = map(int, input().split())
ans_n = (fact(n) // (fact(n - 2) * 2)) if n > 1 else 0
ans_m = (fact(m) // (fact(m - 2) * 2)) if m > 1 else 0
print(ans_n + ans_m)

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

int main() {
  ll k, x;
  cin >> k >> x;
  ll begin = max(x-k, -1000000LL);
  ll end = min(k+x, 1000000LL);
  for (int i = begin+1; i < end; i++) printf("%d ", i);
}

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

const int N = (int)2e3;
const long long MOD = (long long)1e9 + 7;

int data[N+5];
int datb[N+5];

long long dp[N+5][N+5];

int main() {
    for (int i=0; i<N+3; i++) {
        for (int j=0; j<N+3; j++) {
            dp[i][j] = 1;
        }
    }

    int n,m; scanf("%d %d", &n, &m);
    for (int i=1; i<=n; i++) scanf("%d", data+i);
    for (int j=1; j<=m; j++) scanf("%d", datb+j);

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
            if (data[i] != datb[j]) {
                dp[i][j] = (dp[i][j] + MOD - dp[i-1][j-1]) % MOD;
            }
        }
    }

    printf("%lld\n", dp[n][m]);
    return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &v : a) cin >> v;
  for (int i = 0; i < n-1; i++) a[i+1] += a[i];
  sort(a.begin(), a.end());
  ll cnt = 0;
  if (a[0] == 0 && n == 1) cnt++;
  for (int i = 0; i < n-1; i++) {
    ll x = 1;
    if (a[i] == 0) cnt++;
    while (i < n-1 && a[i] == a[i+1]) {
      i++;
      x++;
      if (a[i] == 0) cnt++;
    }
    cnt += x*(x-1)/2;
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 1792
h,w=map(int,input().split())
#aaaaaa
#bbbbbb
#cccccc
x=h*w
for i in range(1,h):
    s=[w*i,w*((h-i)//2), w*(h-i-(h-i)//2)]
    if max(s)-min(s)<x:
        x=max(s)-min(s)
#aaaaaa
#bbbccc
#bbbccc
for i in range(1, h):
    s=[w*i,(h-i)*(w//2),(h-i)*(w-w//2)]
    if max(s)-min(s)<x:
        x=max(s)-min(s)
#aabbcc
#aabbcc
#aabbcc
for i in range(1,w):
    s=[h*i,h*((w-i)//2),h*(w-i-(w-i)//2)]
    if max(s)-min(s)<x:
        x=max(s)-min(s)
#aabbbb
#aacccc
#aacccc
for i in range(1, w):
    s=[h*i,(w-i)*(h//2),(w-i)*(h-h//2)]
    if max(s)-min(s)<x:
        x=max(s)-min(s)
print(x)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  ll current_money = 1000;
  for (int i = 0; i < N - 1; i++) {
    // cout << current_money << endl;
    int today = A.at(i);
    int tomorrow = A.at(i + 1);
    if (tomorrow > today) {
      ll stock = current_money / today;
      current_money = current_money + (tomorrow - today) * stock;
    }
  }

  cout << current_money << endl;
  return 0;
}

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

int main() {
	ll n, k;
	cin >> n >> k;
	ll a[n + 10];
	for(ll i=1; i<=n; i++)
		cin >> a[i];
	ll dp[n+10][k+10];
	dp[0][0] = 1;
	for(ll i=1; i<=k; i++)
		dp[0][i] = 0;
	for(ll i=1; i<=n; i++)
	{
		ll pre[k+10];
		pre[0] = dp[i-1][0];
		for(ll j=1; j<=k; j++)
			pre[j] = (pre[j-1] + dp[i-1][j]) % mod; //dp[i-1][0...j]
			
		for(ll j=0; j<=k; j++)
		{
			ll rem = pre[j];
			ll unreacheable = j - a[i] - 1;
			//cout<<unreacheable;
			if (unreacheable >= 0)
				rem = (rem - pre[unreacheable] + mod) % mod;
			dp[i][j] = rem;
		}
	}
	cout<<dp[n][k];
	return 0;
}

Measured memory_bytes: 81280
# ABC063 D
N, A, B = map(int, input().split())
h = [0] * N
for i in range(N):
    h[i] = int(input())

L = 0
R = sum((h[i]-1) // A + 1 for i in range(N)) + 1
while R - L > 1:
    M = (L+R-1) // 2 + 1
    count = sum((h[i] - B*M - 1) // (A-B) + 1 for i in range(N) if h[i] - B*M > 0)
#     print(L, R, M, count)
    if count > M:
        L = M
    else:
        R = M
print((L+R-1) // 2 + 1)

Measured memory_bytes: 7028
#include <stdio.h>
#define MAX (2*100000)

int main()
{
  int K;
  int N;
  int A[MAX];
  int i;
  int max = -1;
  int length;
  scanf("%d %d", &K, &N);
  for(i = 0; i < N; ++i)
    scanf("%d", &A[i]);
  --i;
  
  for(/*blank*/; i >= 0; --i){
    if(i == 0)
      length = A[0] + (K - A[N - 1]);
    else
      length = A[i] - A[i - 1];
    if(max < length)
      max = length;
  }
  printf("%d\n", K - max);
  return 0;
}

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

using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e18;

int main() {
    string A;
    cin >> A;
    ll l = A.size(), n[26];
    rep(i, 26) n[i] = 0;
    rep(i, l) n[A[i] - 'a']++;
    ll ans = l * (l - 1) / 2 + 1;
    rep(i, 26) ans -= n[i] * (n[i] - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 640
import itertools
import os
import sys

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


S = sys.stdin.buffer.readline().decode().rstrip()

ok = False
for c in itertools.product([True, False], repeat=4):
    s = ''
    if c[0]:
        s += 'A'
    s += 'KIH'
    if c[1]:
        s += 'A'
    s += 'B'
    if c[2]:
        s += 'A'
    s += 'R'
    if c[3]:
        s += 'A'
    ok  |= s == S
if ok:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			String S = sc.next();

			int res = 0;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if ('I' == S.charAt(i))
					count++;
				else
					count--;
				res = Math.max(res, count);
			}

			System.out.println(res);
		} // Scanner Close

	}
}


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

class AtCoderCS {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select((i, j) => int.Parse(i)).ToArray();

        IEnumerable<int> Aright = A.Select((j, k) => k - j + 1);
        int Amax = Aright.Max();

        int[] Aleft = new int[Amax];
        foreach (int i in A.Select((j, k) => j + k + 1))
            if (i <= Amax)
                Aleft[i - 1]++;

        long ans = 0;
        foreach (int i in Aright)
            if (i > 0)
                ans += Aleft[i - 1];

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 44916
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines

n = int(input())
#a = [int(i) for i in readline().split()]

shogen = [None for _ in range(n)]

for i in range(n):
    c = int(input())
    g = []
    for _ in range(c):
        p,q = [int(i) for i in readline().split()]
        g.append([p-1,q])
    
    #print(g)
    shogen[i] = g


def check(mask):
    cnt = 0
    for i in range(n):
        if mask & (1<<i):
            cnt += 1
            for (p,TF) in shogen[i]:
                if mask&(1<<p) != TF<<p:
                    return 0
            
    
    return cnt
    

N = 2**n
ans = 0
for mask in range(N):
    c = check(mask)
    #if c: print(mask,c)
    ans = max(ans,c)    

print(ans)    
    
    
    
    
    
    
    
    
    









Measured memory_bytes: 44636
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>


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

int gcd(int p,int q){
	int a,b;
	a=p;
	b=q;
	while(a!=0&&b!=0){
		if(a<b){
			b=b%a;
		}else{
			a=a%b;
		}
	}
	if(a==0){
		return b;
	}else{
		return a;
	}
}

int main(void)
{
	//変数の宣言
	int n,x;
	int iti[100010];
	int i,j;
	int flag=0;
	int ans;
	//データの読み込み
	scanf("%d %d",&n,&x);
	iti[0]=x;
	for(i=1;i<=n;i++){
		scanf("%d",&iti[i]);
	}
		
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
//	printf("計算部分終了\n");
	
	qsort(iti, n+1, sizeof(int), compare_int);
	
	ans=iti[1]-iti[0];
	
	for(i=1;i<=n;i++){
		iti[i]=iti[i]-iti[0];
		ans=gcd(ans,iti[i]);
	}
	
	//出力
	printf("%d\n",ans);
	
//	printf("結果の出力終了\n");
	
}



Measured memory_bytes: 892
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (0 until n).map {
        readLine()!!.toInt()
    }
    var x = xs[0]
    var ans = Int.MIN_VALUE
    for (i in 1 until n) {
        ans = maxOf(ans, xs[i] - x)
        x = minOf(x, xs[i])
    }
    println(ans)
}


Measured memory_bytes: 52188
s = int(input())

seq = [s]

def f(n):
  if n % 2 == 0:
    return n //2
  else:
    return 3 * n + 1

m = 1
while True:
  i = m-1
  a = f(seq[i])
  
  if a in seq:
    break
  seq.append(a)
  m += 1
print(m+1)

Measured memory_bytes: 61812
#include<stdio.h>

int main()
{
	int N,i=0;
	char str1[51];
	int cnt = 0;
	scanf("%d",&N);
	scanf("%s",str1);
	
	while(i<N-2)
	{
		if(str1[i]=='A' && str1[i+1]=='B' && str1[i+2]=='C')
			cnt++;
		i++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 128
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

int main()
{
	string s;
	cin>>s;
	int x=0;
	for(char z : s)
	{
		if(z=='+')
			x++;
		else
			x--;
	}
	cout<<x;
}





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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int num[100005];
    num[0]=0;
    rep(i,1,n){
        cin >> num[i];
        num[i]+=num[i-1];
    }
    int t=0,ans=0;
    rep(i,0,m){
        int x;
        cin >> x;
        ans += abs(num[t]-num[t+x]);
        ans%=100000;
        t+=x;
        //cout << t << " ";
    }
    cout << ans%100000 << endl;
    return 0;
}

Measured memory_bytes: 3920
s = list(input())
result = []
for i in set(s):
    x = [0]
    y = 0
    for j in range(len(s)):
        if s[j] == i:
            x.append(y)
            y = 0
        else:
            y += 1
    x.append(y)
    if s[-1] == i:
        result.append(max(x))
    else:
        result.append(x[-1]+max(0, max(x[:-1])-x[-1]))
print(min(result))

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();

        int[] A = new int[N];

        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextInt();
        }

        int[] tmp1 = new int[N + 1];
        int[] tmp2 = new int[N + 1];

        tmp1[0] = 0;
        for (int i = 1; i <= N; i++)
        {
            tmp1[i] = Math.Max(tmp1[i - 1], A[i - 1]);
        }

        tmp2[N] = 0;
        for (int i = N - 1; i >= 0; i--)
        {
            tmp2[i] = Math.Max(tmp2[i + 1], A[i]);
        }

        for (int i = 0; i < N; i++)
        {
            Console.WriteLine(Math.Max(tmp1[i], tmp2[i + 1]));
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 18744
def f(n):
    res = set()
    for i in range(2, int(n ** 0.5) // 1):
        if n % i: continue
        while not n % i: n //= i
        res.add(i)
    return res | {n}

a, b = map(int,input().split())
print(len(f(a) & f(b) | {1}))


Measured memory_bytes: 2940
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
   long long  a;
   cin>>a;
   vector<long long> avec(a+1);
   vector<long long> bvec(a);
   rep(i,a+1){
      cin>>avec.at(i);
   }
   rep(i,a){
      cin>>bvec.at(i);
   }
   long long count=0;
   rep(i,a){
      if(avec.at(i)<bvec.at(i)){
         count+=avec.at(i);
         if(avec.at(i+1)-(bvec.at(i)-avec.at(i))>=0){
            avec.at(i+1)-=bvec.at(i)-avec.at(i);
            count+=bvec.at(i)-avec.at(i);
         }
         else{
            count+=avec.at(i+1);
            avec.at(i+1)=0;
         }
      }
      else{
         count+=bvec.at(i);
      }
   }
   cout<<count<<endl;

}



Measured memory_bytes: 1920
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

long long int digit_sum(long long int n) {
	int a = 0;
	while (n) {
		a += n % 10;
		n /= 10;
	}
	return a;
}

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

	cin >> K;
	vector<long long int>v;
	for (int i = 1; i < 10; i++)v.push_back(i);
	v.push_back(19);
	long long int last = 19;
	while (v.size() < K) {
		long long int p = digit_sum(last);
		long long int box = last / p;
		long long int add = 1;
		while ((last + add)*digit_sum(last + add * 2) > (last + add * 2)*digit_sum(last + add)) {
			add *= 10;
		}
		last += add;
		v.push_back(last);
	}
	//for (auto i : v) {
	//	cout << (long double)i / digit_sum(i) << endl;
	//}
	for (int i = 0; i < K; i++) {
		cout << v[i] << endl;
	}
	return 0;
}

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

int main(){
    int N;
    cin >>N;
    vector<int> b;
    int tmp;
    vector<int> ans;
    for (int i=0;i<N;i++){
        cin >>tmp;
        b.push_back(tmp);
    }
    bool flag;

    for(int j=N-1;j>=0;j--){
        flag=false;
        for (int i=j;i>=0;i--){
            if(b[i]==i+1){
                ans.push_back(i+1);
                b.erase(b.begin()+i);
                flag=true;
                //cout <<i+1<<endl;
                break;
            }
        }
        if(flag==false){
            cout <<-1<<endl;
            return 0;
        }
    }
    // reverse(ans.begin(),ans.end());
    for(int i=N-1;i>=0;i--){
        cout<<ans[i]<<endl;
    }

}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)
#define PI 3.141592653589793

                                        
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  string s; cin >> s;
  set<char> ss;
  int size = (int)s.size();
  forn(i , 0 , size) ss.insert(s[i]);
  cout << ((ss.size() == 2) ? "Yes" : "No") << endl;
  
#ifdef LOCAL_DEFINE 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)
        res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       
        ll r;cin>>r;long double ar;
        cout<<fixed<<setprecision(10);
        ar=r*2*acos(-1);
        cout<<ar;
}


Measured memory_bytes: 3824
#include<cstdio>
#include<algorithm>
using namespace std;
 
int main(){
  int h, w, ans;
  scanf("%d%d", &h, &w);
  if(!(h%3) || !(w%3)) ans = 0;
  else{
    if(!(w%2)) ans = w/2;
    else ans = h/3*2+1 > w ? w : (w+h/3*2+1)/2;
    if(!(h%2)) ans = min(ans, h/2);
    else ans = min(ans, w/3*2+1 > h ? h : (h+w/3*2+1)/2);
  }
  printf("%d\n", ans);
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int digit(int n)
{
    int res = 0;
    while (n)
    {
        n /= 10;
        res++;
    }
    return (res);
}

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

    int ans = 0;
    rep2(i, 1, n + 1)
    {
        if (digit(i) & 1)
        {
            ans++;
        }
    }

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


Measured memory_bytes: 3480
import numpy as np

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

# 0 <= A, B, C <= 50

max_v = max(max(A, B), C)

res = 3 * max_v - (A + B + C)
if res % 2 == 0:
    f = int(res / 2)
    print(f)
else:
    res += 3
    f = int(res / 2)
    print(f)


Measured memory_bytes: 12496
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};

int a[100005],dp[100005];

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

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

	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	dp[0]=0;
	
	for(int i=1;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j<0) break;
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}

	cout<<dp[n-1];


	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> s;
  rep(i, n) {
    cin >> a[i];
    s.insert(a[i]);
  }

  if (s.size() == n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 10496
def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [0] * (N + 1)
    for i in range(N):
        dp[i + 1] = max(abs(a[i] - W), abs(a[i - 1] - a[i]))
    print(dp[-1])


main()


Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1001000,P=998244353;
int i,j,k,n,m,ans,sum,suml,sumr;
int Jc[N],Jc_[N],inv[N];
int ksm(int x,int y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
void pre(int n) {
	int i;
	Jc[0]=Jc_[0]=1;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
	Jc_[n]=ksm(Jc[n],P-2);
	for (i=n-1;i;i--) Jc_[i]=(ll) Jc_[i+1]*(i+1)%P;
	for (i=1;i<=n;i++) inv[i]=(ll) Jc_[i]*Jc[i-1]%P;
}
int C(int n,int m) {
	if (n<m) return 0;
	return (ll) Jc[n]*Jc_[m]%P*Jc_[n-m]%P;
}
int Js(int x1,int y1,int x2,int y2) {
	return C(x2-x1+y2-y1,x2-x1);
}
int main() {
	scanf("%d%d",&n,&m);
	pre(n+m);
	if (n<m) swap(n,m);
	sum=C(n+m,n);suml=C(n+m-1,n);sumr=C(n-1+m,n-1);
	for (i=1;i<=m+m;i++) {
		ans=((ll) sum*inv[i]+ans)%P;
		int x=(i+1)/2;
		if (i&1) {
			suml=(suml+P-(ll) Js(0,0,x-1,x-1)*Js(x,x-1,n,m-1)%P)%P;
			sumr=(sumr+P-(ll) Js(0,0,x-1,x-1)*Js(x-1,x,n-1,m)%P)%P;
		}
		else {
			suml=(suml+(ll) Js(0,0,x,x-1)*Js(x,x,n,m-1))%P;
			sumr=(sumr+(ll) Js(0,0,x-1,x)*Js(x,x,n-1,m))%P;
		}
		sum=((sum+suml)%P+sumr)%P;
	}
	for (;i<=n+m;i++) {
		ans=((ll) sum*inv[i]+ans)%P;
		sum=(sum+sumr)%P;
	}
	ans=(ll) ans*ksm(C(n+m,n),P-2)%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 11904
#include <stdio.h>
char Grading(m,f,r){
	int t;
	char grade;
	t=m+f;
	
	if(m==-1||f==-1){
			grade='F';
		}
	else if(t>=80){
		grade='A';
	}
	else if(t>=65&&t<80){
		grade='B';
	}
	else if(t>=50&&t<65){
		grade='C';
	}
	else if(t>=30&&t<50){
		if(r>=50){
			grade='C';
		}
		else{
			grade='D';
		}
	}
	else{
		grade='F';
	}

	return grade;
}


int main(void){

	int m,f,r;
	char grade;
	
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		grade=Grading(m,f,r);
		printf("%c\n",grade);
	}

	return 0;
}

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


int main(){
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	int cont=1;
	
	for (int i=1; i<n; i++){
		if (s[i]!=s[i-1]) cont++;
	}
	
	cout<<cont<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool cmp (int i, int j) {
  return a[i] < a[j];
}
int main() {
  int n;
  cin >> n;
  int N = (1 << n);
  a.resize(N);
  vector<int> ret(N), M(N), m(N);
  for (int bs = 0; bs < N; bs++) cin >> a[bs];
  M[0] = 0;
  m[0] = 0;
  for (int bs = 1; bs < N; bs++) {
    vector<int> rpr;
    for (int i = 0; i < n; i++) if ((bs >> i) & 1) {
      int cs = bs - (1 << i);
      rpr.emplace_back(M[cs]);
      rpr.emplace_back(m[cs]);
    }
    rpr.emplace_back(bs);
    sort(rpr.begin(), rpr.end(), cmp);
    rpr.resize(unique(rpr.begin(), rpr.end()) - rpr.begin());
    auto it = rpr.end();
    M[bs] = *(--it);
    m[bs] = *(--it);
    ret[bs] = a[M[bs]] + a[m[bs]];
  }
  for (int bs = 2; bs < N; bs++) {
    ret[bs] = max(ret[bs], ret[bs - 1]);
  }
  for (int bs = 1; bs < N; bs++) {
    cout << ret[bs] << endl;
  }
  return 0;
}

Measured memory_bytes: 7168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();
		String T = scan.next();

		if (T.substring(0, T.length() - 1).equals(S)) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 35684
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    ll k;
    cin >> k;
    
    ll count = 1;
    ll n = 7;
    if(k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }

    while(n % k > 0){
        n = (n * 10 + 7) % k;
        count++;
    }
    cout << count << endl;

    
    return 0;
}

Measured memory_bytes: 3164
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String str = sc.next();
        char c[] = str.toCharArray();
        int intc = (int)c[0] + 1;
        char result = (char)intc;
        // 出力
        System.out.println(result);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L=A+B;
  R=C+D;
  if (L<R) {
    cout << "Right" << endl;
  }
  else {
    if (L>R) {
      cout << "Left" << endl;
    }
    else {
      cout << "Balanced" << endl;
    }
  }
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> crd(n);
	for (int i = 0; i < n; i++)
	{
		cin >> crd.at(i);
	}
	sort(crd.rbegin(), crd.rend());
	int a = 0;
	int b = 0;
	for (int i = 0; i < n; i++)
	{
		if(!(i%2)) a += crd.at(i);
		else b += crd.at(i);
	}
	cout << (max(a, b) - min(a, b)) << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n,d; cin >> n >> d;
    ll ans = 0;
    while(n--){
        ld x, y; cin >> x >> y;
        if( ceil(sqrt(x*x + y*y)) <= d) ans ++;
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3824
f :: String->[Int]
f x=map read (words x)::[Int]

f2::[Int]->[Int]->Int->Int
f2 [] _ ans=ans
f2 (x:xs) (x2:xs2) ans=f2 xs xs2 (max (ans+x2) (x+x2))
                  

main = do
        e <- getLine
        e1 <- getLine
        e2 <- getLine
        let xs=f e1
            xs2=f e2
            zs=scanl1 (+) xs
        putStrLn $ show $ f2 zs xs2 0

Measured memory_bytes: 1020
t=input()
N=int(t.split()[0])
M=int(t.split()[1])

city=[0]*M
for i in range(M):
  te=[int(x) for x in input().split()]
  city[i]={'i':i+1,'p':int(te[0]),'y':int(te[1])}

city_sorted = sorted(city,key = lambda x: (x['p'], x['y']))

x=0
temp_p=city_sorted[0]['p']
for c in city_sorted:
  if temp_p == c['p']:
    x+=1
  else:
    temp_p=c['p']
    x=1
  c['id']="{0:06d}{1:06d}".format(c['p'],x)
  
for ci in city:
  print(ci['id'])
  

Measured memory_bytes: 52020
import java.util.*;

public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
	String str = sc.next();
    if(str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5)){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

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

signed main(void) {
	int n;
	cin >> n;
	vector<int> l(n);

	int rui[3005] = {};

	REP(i, n) {
		cin >> l[i];
		rui[l[i]]++;
	}

	REP(i, 3002) {
		rui[i + 1] += rui[i];
	}

	// rui (]
	ll ans = 0;

	REP(i, n) {
		rep(j, 0, n) {
			if (i == j) continue;

			int lb = abs(l[i] - l[j]), ub = l[i] + l[j];

			int cou = max(0, rui[ub - 1] - rui[lb]);
			if (l[i] > lb && l[i] < ub) cou--;
			if (l[j] > lb && l[j] < ub) cou--;

			ans += 1LL*cou;
		}
	}
	cout << ans / 6LL << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



string str;

int main() {
    while (cin >> str) {
        int res = 0;
        int lj = 0, lo = 0, li = 0;
        for (int i = 0; i < str.size(); ++i) {
            if (str[i] == 'J') {
                lj = 0, lo = 0, li = 0;
                
                int j; 
                for (j = i; j < str.size(); ++j) {
                    if (str[j] == 'J') ++lj;
                    else break;
                }
                if (j == str.size()) break;
                if (str[j] != 'O') continue;
                
                int k;
                for (k = j; k < str.size(); ++k) {
                    if (str[k] == 'O') ++lo;
                    else break;
                }
                if (k == str.size()) break;
                if (str[k] != 'I') continue;
                
                int l;
                for (l = k; l < str.size(); ++l) {
                    if (str[l] == 'I') ++li;
                    else break;
                }
                
                if (lj >= lo && li >= lo) chmax(res, lo);
                i = k-1;
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if (0 <= x - r && 0 <= y - r && x + r <= w && y + r <= h) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3108
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
  int r=sc.nextInt();
  int c=sc.nextInt();
  char grid[][]=new char[r][c];
  int dp[][]=new int[r][c];
  for(int i=0;i<r;i++){
      String a=sc.next();
  for(int j=0;j<c;j++){
  grid[i][j]=a.charAt(j);
    if(grid[i][j]=='#')
      dp[i][j]=-1;
  }
  }
  dp[0][0]=1;
  
  for(int i=0;i<r;i++){
  for(int j=0;j<c;j++){
    if(i==0&&j==0)
      continue;
    if(dp[i][j]==-1)
      continue;
    
    if(j-1>=0&&dp[i][j-1]!=-1){
    dp[i][j]+=dp[i][j-1]%1000000007;
    }
    if(i-1>=0&&dp[i-1][j]!=-1){
    dp[i][j]+=dp[i-1][j]%1000000007;
    }
    
  }  
  }
  System.out.println(dp[r-1][c-1]%1000000007);
}
}

Measured memory_bytes: 34484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c,d;
int saf;
char atai[5];
char en[2] = {'+', '-'};
int main(){
  scanf("%s", &atai);
  a = atai[0]-'0';
  b = atai[1]-'0';
  c = atai[2]-'0';
  d = atai[3]-'0';
  for(int i=0 ; i<2 ; i++){
    for(int j=0 ; j<2 ; j++){
      for (int ks = 0; ks <2; ks++) {
          int sum = a;
          if(i==0)sum+=b;
          else sum-=b;
          if(j==0)sum+=c;
          else sum-=c;
          if(ks==0)sum+=d;
          else sum-=d;
          if(sum == 7){
            cout<<a<<en[i]<<b<<en[j]<<c<<en[ks]<<d<<'='<<7<<endl;
            return 0;
          }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,q=MI()
lis1=[-inf]
lis2=[-inf]
for i in range(a):
    lis1.append(I())
for i in range(b):
    lis2.append(I())
lis1.append(inf)
lis2.append(inf)
#print(lis1)
#print(lis2)
for i in range(q):
    u=I()
    x=bisect_left(lis1,u)
    y=bisect_left(lis2,u)
    #print(u,x,y)
    Lll=u-min(lis1[x-1],lis2[y-1])
    Lrr=max(lis1[x],lis2[y])-u
    Llr1=2*(u-lis1[x-1])+(lis2[y]-u)
    Llr2=2*(lis2[y]-u)+u-lis1[x-1]
    Lrl1=2*(u-lis2[y-1])+lis1[x]-u
    Lrl2=2*(lis1[x]-u)+u-lis2[y-1]
    #print(Lll,Lrr,Lrl1,Lrl2,Llr1,Llr2)
    print(min(Lll,Lrr,Lrl1,Lrl2,Llr1,Llr2))
    
    
    
    



Measured memory_bytes: 87232