akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Function
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.Vector as VB
import qualified Data.Vector.Mutable as VBM
-- import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce
import GHC.Exts (build)



code :: Int -> Int -> Int
code p k = 10^12 + 10^6 * p + k

{-
query' :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int
query' n m vec = VB.create $ do
  dictmut <- VBM.replicate n $ IntMap.empty
  V.imapM_ (\i (p,y) -> do entry <- VBM.read dictmut (p-1)
                           VBM.write dictmut (p-1)
                             $! IntMap.insert y i entry) vec
-}  

query :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int
query n m vec
  = V.replicate m 0 V.// codes
  where
    vec' :: VB.Vector (Int, (Int, Int))
    vec' = VB.convert $ V.imap (\i (p,y) -> (p-1,(y,i))) vec
    dict :: VB.Vector [(Int,Int)]
    dict = VB.accumulate (flip (:)) (VB.replicate n []) vec'
    codes :: [(Int,Int)]
    codes = concat $ VB.toList $
      VB.imap (\pm1 -> zipWith (\k (y,i) -> (i,code (pm1+1) k)) [1..]
                                 . sortBy (compare `on` fst)) dict 

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  rest <- B.getContents
  let vec = V.unfoldrN m (\b -> let (l,r) = B.span (/= '\n') b in
                             Just (decode l, B.tail r)) rest
      decode l = (p,y)
        where Just (p, l1) = B.readInt l
              Just (y, _ ) = B.readInt $ B.dropWhile (== ' ') l1
  V.mapM_ (putStrLn . tail . show) $ query n m vec


Measured memory_bytes: 45692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];
    
    vector<ll> plus(n + 1, 0);
    rep(i, n) plus[i + 1] = plus[i] + (a[i] > 0 ? a[i] : 0);
    // outa(plus, n + 1);
    
    vector<ll> ksum(n + 1, 0);
    rep(i, k) ksum[k] += a[i];
    rep3(i, k, n) {
        ksum[i + 1] = ksum[i] + a[i] - a[i - k];
    }
    // outa(ksum, n + 1);
    
    ll ans = 0;
    rep3(i, k, n + 1) {
        ll tmp = 0;
        tmp = ksum[i];
        tmp += plus[n] - plus[i];
        tmp += plus[i - k];
        // out(tmp << " " << ksum[i] << " " << plus[n] << " " << plus[i] << " " << plus[i - k]);
        
        chmax(ans, tmp);
    }
    // out(ans);
    
    // kマス白パターン sample 2
    rep3(i, k, n + 1) {
        ll tmp = 0;
        tmp += plus[n] - plus[i];
        tmp += plus[i - k];
        
        chmax(ans, tmp);
    }
    
    out(ans);
}



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

int main()
{
    std::string s;
    std::vector<std::pair<char, long long>> p;
    long long k;
    std::cin >> s;
    std::cin >> k;

    char c = s[0];
    long long cnt = 1;
    for (size_t i = 1; i < s.length(); i++) {
        if (c == s[i]) {
            cnt++;
        } else {
            p.emplace_back(c, cnt);
            c = s[i];
            cnt = 1;
        }
    }
    p.emplace_back(c, cnt);

    long long ans = 0;
    for (size_t i = 0; i < p.size(); i++) {
        ans += (p[i].second / 2);
    }

    ans *= k;

    if (p.size() == 1) {
        if (s.length() == 1)
            ans = k / 2;
        else
            ans = p[0].second * k /2;
    } else if (p[0].first == p[p.size()-1].first) {
        long long a = p[0].second / 2 + p[p.size()-1].second / 2 - (p[0].second+p[p.size()-1].second)/2;
        ans-= (a*(k-1));
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  cin >> n;
  long long int ans=1e6;
  for(int i=1;i<=n/2;i++){
    int j=n-i,k=i; long long int cnt=0,cnt1=0;
    while(1){
      if(j==0) break;
      cnt+=(j%10);
      j/=10;
    }
    while(1){
      if(k==0) break;
      cnt1+=(k%10);
      k/=10;
    }
    ans=min(ans,cnt+cnt1);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;
alias Prefecture = Tuple!(long, "ward", long, "established", long, "number");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m;
    scan(n, m);
    auto id = new Prefecture[](m);
    foreach (i; 0 .. m)
    {
        long ward, established;
        scan(ward, established);
        id[i] = Prefecture(ward, established, i);
    }
    id.sort!"a.ward == b.ward ? a.established < b.established : a.ward < b.ward"();
    long count, corrent = id[0].ward;
    foreach (ref e; id)
    {
        if (corrent == e.ward)
        {
            e.established = ++count;
        }
        else
        {
            corrent = e.ward;
            count = 0;
            e.established = ++count;
        }
    }
    id.sort!"a.number < b.number"();
    foreach (e; id)
    {
        writef("%06s%06s", e.ward, e.established);
        writeln();
    }
}

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  x -= z;
  cout << x / (y + z) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

A = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
# print(A)
# print(b)

done = [[0] * 3 for _ in range(3)]
for k in range(N):
    for i in range(3):
        for j in range(3):
            if b[k] == A[i][j]:
                done[i][j] = 1
# print(done)

ans = "No"
for i in range(3):
    flg = True
    for j in range(3):
        if done[i][j] == 0:
            flg = False
    if flg:
        ans = "Yes"
for i in range(3):
    flg = True
    for j in range(3):
        if done[j][i] == 0:
            flg = False
    if flg:
        ans = "Yes"

flg = True
for j in range(3):
    if done[j][j] == 0:
        flg = False
if flg:
    ans = "Yes"
flg = True
for j in range(3):
    if done[2-j][j] == 0:
        flg = False
if flg:
    ans = "Yes"

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

char s[105];

int main(){
	scanf("%s", s);
	
	int len = strlen(s);
	
	cout << s[0] << len-2 << s[len-1] << endl;
	
	return 0;
}

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

int main() {
  int a, b, c, d, tmp;
  int gcd, lcm;
  while(cin >> a >> b) {
    c = a;
    d = b;
    while(true) {
      if(c == d) break;

      if(c > d) {
        tmp = c;
        c = d;
        d = tmp;
      }

      d -= c;
    }
    gcd = c;
    lcm = (a/gcd) * b;
    cout << gcd << " " << lcm << endl;
  }

  return 0;
}

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

int main(){
    int l,r;cin>>l>>r;
    int minval=100000;
    if(r-l>=2019){
      cout<<0<<endl;
      return 0;
    }
    l=l%2019;r=r%2019;
    if(r<l){
      cout<<0<<endl;
      return 0;
    }
    for(int i=l;i<=r-1;i++){
      for(int j=i+1;j<=r;j++){
        if(minval>(i*j%2019)){
          minval=i*j%2019;
        }
      }
    }
    cout<<minval<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define  inf 0x3fffffff 
int main()
{
	int i, n,x,a[110000];
	long long sum;
	while (~scanf("%d%d", &n, &x))
	{
		sum = 0;
		for (i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		if (a[1] > x)
		{
			sum += a[1] - x;
			a[1] = x;
		}
		for (i = 2; i <= n; i++)
		{
			int flag = a[i] + a[i - 1] - x;
			if (flag > 0)
			{
				sum += flag;
				a[i] -= flag;
			}
		}
		printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true){
            int H = scanner.nextInt(), W = scanner.nextInt();
            if(H==0 && W==0) break;
            for (int j=0;j<H;j++) {
                for(int i=0;i<W;i++){
                    if(0==((i+j)%2)) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35712
lines = input().split()
W = int(lines[0])
a = int(lines[1])
b = int(lines[2])
shortest = b-(a+W)
s2 = a-(b+W)
if shortest >= 0 :
    print(shortest)
elif shortest <= 0 and s2>=0:
    print(s2)
else:
    print("0")

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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,A[70000],mx,mi;
int main()
{
	n=read(); for(int i=1;i<=n;i++)
	{
		A[i]=read();
		if(!mx||A[i]>A[mx]) mx=i;
		if(!mi||A[i]<A[mi]) mi=i;
	}
	printf("%d\n",2*n-2);
	if(abs(A[mx])>abs(A[mi]))
	{
		for(int i=1;i<=n;i++) if(i!=mx) printf("%d %d\n",mx,i);
		for(int i=1;i<n;i++) printf("%d %d\n",i,i+1);
	}
	else if(abs(A[mx])<=abs(A[mi]))
	{
		for(int i=1;i<=n;i++) if(i!=mi) printf("%d %d\n",mi,i);
		for(int i=n;i>1;i--) printf("%d %d\n",i,i-1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
 int c;
  c=a*b;
  if(c%2 == 0){
  cout<<"Even"<<endl;
    
  }
  else{
  cout<<"Odd"<<endl;
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := map[int]int{}
	var a, maxA int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		as[a]++
		if a > maxA {
			maxA = a
		}
	}

	var max int
	for x := 0; x < maxA+1; x++ {
		cnt := as[x] + as[x-1] + as[x+1]
		if cnt > max {
			max = cnt
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxH=10, mxW=1e3;
int h, w, k, ans=1e9;
string g[mxH];
vector<int> v[mxW];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> h >> w >> k;
	for(int i=0; i<h; ++i)
		cin >> g[i];
	for(int i=0; i<1<<h-1; ++i) {
		int ca=__builtin_popcount(i);
		for(int j=0; j<w; ++j) {
			int s=0;
			for(int k=0; k<h; ++k) {
				s+=g[k][j]&1;
				if(i>>k&1) {
					v[j].push_back(s);
					s=0;
				}
			}
			v[j].push_back(s);
			for(int vi : v[j])
				if(vi>k)
					ca=1e9;
		}
		vector<int> u(v[0].size());
		for(int j=0; j<w; ++j) {
			bool split=0;
			for(int l=0; l<u.size(); ++l)
				split|=u[l]+v[j][l]>k;
			if(split) {
				++ca;
				u=vector<int>(u.size());
			}
			for(int l=0; l<u.size(); ++l)
				u[l]+=v[j][l];
			v[j].clear();
		}
		//cout << i << " " << ca << endl;
		ans=min(ca, ans);
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<stdio.h>

int S[10000];
int N;

int linearSearch(int);

int main(){
  int q, T[500], i, c = 0;

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

  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&T[i]);
    c += linearSearch(T[i]);    
  }
  printf("%d\n",c);
  return 0;
}

int linearSearch(int key){
  int i = 0;
  S[N] = key;
  while(S[i] != key){
    i++;
    if(i == N)
      return 0;
  }  
  return 1;
}

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

for i in range(n):
  b.append(int(input()))

#print(a, b)

for i in range(len(b)):
  a = [0 if mas == b[i] else mas for mas in a]

if a[0] == 0 and a[1] == 0 and a[2] == 0\
   or a[3] == 0 and a[4] == 0 and a[5] == 0\
   or a[6] == 0 and a[7] == 0 and a[8] == 0\
   or a[0] == 0 and a[3] == 0 and a[6] == 0\
   or a[1] == 0 and a[4] == 0 and a[7] == 0\
   or a[2] == 0 and a[5] == 0 and a[8] == 0\
   or a[0] == 0 and a[4] == 0 and a[8] == 0\
   or a[2] == 0 and a[4] == 0 and a[6] == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int N;
    scanf("%d", &N);
    unsigned long long int h, n, w;
    for (h = 1; h < 3501; h++)
    {
        for (n = h; n < 3501; n++)
        {
            if (4 * h*n - N * n - N * h > 0)
            {
                if ((N*h*n) % (4 * h*n - N * n - N * h) == 0)
                {
                    w = (N*h*n) / (4 * h*n - N * n - N * h);
                    printf("%lld %lld %lld\n", h, n, w);
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[200010];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int k;
        cin>>k;
        cnt[k]++;
    }
    for(int i=1;i<=n;i++)
        cout<<cnt[i]<<'\n';

}

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

int main()
{
  int n;
  cin>>n;
  int arr[n][2];
  int i=0;
  for( i=0;i<n;i++)
  {
    cin>>arr[i][0];
    cin>>arr[i][1];
  }
  i=0;
  while(i<n-2)
  {
    if(arr[i][0]==arr[i][1]&&arr[i+1][0]==arr[i+1][1]&&arr[i+2][0]==arr[i+2][1])
    {
      cout<<"Yes";
      return 0;
    }
      i++;
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		List<List<Integer>> alp = new ArrayList<>();
		
		for(int i = 0 ; i < 26 ;i++) {
			alp.add(new ArrayList<>());
		}
		
		for(int i = 0 ;i < s.length() ;i++) {
			int id = s.charAt(i)-'a';
			alp.get(id).add(i);
		}
		
		
		for(int i = 0 ; i < t.length(); i++) {
			int p = t.charAt(i)-'a';
			if(alp.get(p).isEmpty()) {
				System.out.println(-1);
				return;
			}
		}
		
		int f = -1;
		int len = 1;
		
		for(int i = 0 ; i < t.length() ; i++) {
			int p = t.charAt(i)-'a';
			int q = binary_search(alp.get(p),f);
			if(q == -1) {
				len++;
				f = alp.get(p).get(0);
			}
			else {
				f = q;
			}			
		}
		
		long ans = (long)(len-1) * s.length() + f+1;
		System.out.println(ans);
		

	}
	
	static int binary_search(List<Integer> alp, int f) {
		
		int l = 0;
		int r = alp.size()-1;
		int mid =(l+r)/2;
		
		
		if(alp.get(r) <= f) {
			return -1;
		}
		if(alp.get(0) > f) {
			return alp.get(0);
		}
		
		while(r-l > 1) {
			mid = (l+r)/2;
			
			if(alp.get(mid) > f) {
				r = mid; 
			}
			else if(alp.get(mid) < f) {
				l = mid;
			}
			else {
				return alp.get(mid+1);
			}
		}
		return alp.get(r);
		
	}
	
}


Measured memory_bytes: 43208
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

int A, B;

int main()
{
	in >> A >> B;

	if (A + B >= 24)
	{
		out << A + B - 24 << std::endl;
	}
	else
	{
		out << A + B << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, K;
  string S;
  cin >> N >> K >> S;
  S[K-1] += 32;
  cout << S << endl;
  return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int n;
    long sum=0;
    cin >> n;
    rep(i, n+1){
        if(i%3!=0&&i%5!=0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int children = sc.nextInt();
        int result = 0;
        for (int i = 1; i <= children; i++) {
            result += i;
        }
        
        System.out.println(result);
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=2010;
const int Mod=998244353;
char Str[MAXN];
int n,Ans,Seq[MAXN],Pre[MAXN],Dp[MAXN][MAXN],C[MAXN][MAXN];
inline void Add(rg int &A,rg int B){   A+=B,A-=A>=Mod?Mod:0;   }
int main()
{   scanf("%s",Str+1),n=strlen(Str+1);
	for(rg int i=0;i<=n;i++) C[i][0]=1;
	for(rg int i=1;i<=n;i++) Seq[i]=Str[i]-'0',Pre[i]=Pre[i-1]+Seq[i];
	for(rg int i=1;i<=n;i++)
		for(rg int j=1;j<=i;j++) C[i][j]=C[i-1][j],Add(C[i][j],C[i-1][j-1]);
	Dp[0][0]=1;
	for(rg int i=1;i<=n;i++)
		for(rg int j=0;j<=i;j++)
		{   if(Pre[i-1]+(Seq[i]!=0)>=j) Add(Dp[i][j],Dp[i-1][j-1]);
			if(2*i-2-Pre[i-1]+(Seq[i]<=1)>=i-j) Add(Dp[i][j],Dp[i-1][j]);
		}
	for(rg int i=0;i<=n;i++) Add(Ans,1ll*Dp[n][i]*C[n][Pre[n]-i]%Mod);
	printf("%d\n",Ans);
}


Measured memory_bytes: 30848
#include<bits/stdc++.h>
#define ll long long int
#define pb(i) push_back(i)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       ll a[n];
       for(int i=0;i<n;i++)
        cin>>a[i];
        ll totalheights=0;
        ll minv=a[0];
       for(int i=1;i<n;i++)
       {
          if(a[i]<minv)
            totalheights+=minv-a[i];
          else
            minv=a[i];
       }
       cout<<totalheights;
    }
}


Measured memory_bytes: 5148
# include <iostream>
# include <vector>
# include <string>
using namespace std;
int main() {
	int n, a;
	while (cin >> n&&n != 0) {
		int sum = 0, min = 10000, max = 0;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (a < min) {
				min = a;
			}
			if (max < a) {
				max = a;
			}
			sum += a;
		}
		sum = sum - max - min;
		cout << sum / (n - 2) << endl;
	}
}

Measured memory_bytes: 3008
import sys
import collections

n, m = map(int, sys.stdin.readline().split())
p = list(range(n))
r = [1] * n


def li_(): return [int(x)-1 for x in sys.stdin.readline().split()]


def find(x):
    global p
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    if y > x:
        x, y = y, x
    p[y] = x
    r[x] += r[y]
    r[y] = r[x]


flist = [0] * m
elist = [0] * m
for i in range(m):
    flist[i], elist[i] = li_()

flist.reverse()
elist.reverse()

ans = [0] * m
ans[0] = int(n*(n-1)/2)

for i in range(m-1):
    a, b = flist[i], elist[i]
    if find(a) != find(b):
        ans[i + 1] = ans[i] - r[find(a)]*r[find(b)]
        union(a, b)
    else:
        ans[i+1] = ans[i]
    if ans[i+1] == 0:
        break

for i in range(m):
    print(ans[m-i-1])


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

int a[12][12];
 
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
        cost = cost + c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if(d[j] < x) ok = false;
    if(ok) ans = min(ans, cost);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  string s, t;
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" <<endl;
  else cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

vi g[N];
int a[N];

void solve() {
	int i, j, n;
	double m, c;

	cin >> n >> m;

	long long int arr[n][2];

	fo(i, n)
	{

		cin >> arr[i][0] >> arr[i][1];
	}


	int count = 0;
	fo(i, n)
	{


		c = sqrt(pow(arr[i][0], 2) + pow(arr[i][1], 2));

		//deb2(c, m);

		if (c <= m)
			count++;


	}


	cout << count << '\n' ;


}







int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());

	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}







Measured memory_bytes: 13928
n = int(input())
list_a = list((map(int, input().split())))
memo = 0
memo_dict = {0:1}
for i in range(0,n):
    memo += list_a[i]
    if memo in memo_dict:
        memo_dict[memo] += 1
    else:
        memo_dict[memo] = 1
ans = 0
for number in memo_dict.values():
    ans += number * (number-1) / 2
print(int(ans))


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

const int M=21;
const int MO=1e9+7;

inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}

int g[M+5];
int cnt[(1<<M)+5];
int dp[(1<<M)+5];

int main()
{
	int n; scanf("%d",&n);
	int aij;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%d",&aij);
			g[i]|=aij<<j;
		}
	}
	dp[0]=1;
	int mask=(1<<n)-1;
	for(int i=1;i<=mask;i++)
		cnt[i]=cnt[i>>1]+(i&1);
	for(int i=0;i<mask;i++)
	{
		int u=cnt[i];
		for(int j=0;j<n;j++)
		{
			if((i&(1<<j))||!(g[u]&(1<<j))) continue;
			addv(dp[i|(1<<j)],dp[i]);
		}
	}
	printf("%d\n",dp[mask]);
	return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    Cinm(int, n, m);
    int ans = 0;
    for(int i = 1; i <= 100000-2; i ++){
        int a = m[i-1] + m[i] + m[i+1];
        ans = max(a, ans);
    }
    Cout(ans);
}


Measured memory_bytes: 4388
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    k = int(input().strip())
    a,b = map(int,input().strip().split())
    for i in range(a,b+1):
        if i%k==0:
            print("OK")
            return
    print("NG")



if __name__ == '__main__':
    main()

Measured memory_bytes: 78412
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  string s;
  cin >> n >> s;
  auto allseen = [&](vecint s) -> bool {
    REP(i, 10) {
      if (s[i] == 0) return false;
    }
    return true;
  };
  int ans = 0;
  vecint seen1(10, 0);
  REP(i, n) {
    // cout << i << endl;
    if (allseen(seen1)) break;
    if (seen1[s[i] - '0'] == 1) continue;
    seen1[s[i] - '0'] = 1;
    vecint seen2(10, 0);
    for (int j = i + 1; j < n; j++) {
      // cout << j << endl;
      if (allseen(seen2)) break;
      if (seen2[s[j] - '0'] == 1) continue;
      seen2[s[j] - '0'] = 1;
      vecint seen3(10, 0);
      for (int k = j + 1; k < n; k++) {
        if (allseen(seen3)) break;
        // cout << i << " " << j << " " << k << " ";
        // cout << seen1[s[i] - '0'] << " " << seen2[s[j] - '0'] << " "
        //      << seen3[s[k] - '0'] << endl;
        if (seen3[s[k] - '0'] == 1) continue;
        seen3[s[k] - '0'] = 1;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int n, a[303000], s[303000];

bool chk(int aim){
    int mn=0;
    for (int i=1;i<n;i+=2)
        if (s[i]-mn>=aim)
            mn=min(mn,s[i+1]);
    return s[n]-mn>=aim;
}

void fuck1(){
    for (int i=1;i<=n;++i)
        s[i]=s[i-1] + (i&1? a[i]: -a[i]);
    int l=0, r=3e8, ans=0;
    for (;l<=r;){
        int mid=l+r>>1;
        if (chk(mid)) l=mid+1, ans=mid;
        else r=mid-1;
    }
    int sum=0;
    for (int i=1;i<=n;++i){
        sum+=a[i];
        if (~i&1) ans+=a[i]; 
    }
    cout<<ans<<' '<<sum-ans<<endl;
}

void fuck0(){
    int s[2]={0,0};
    for (int i=1;i<=n;++i) s[i%2]+=a[i];
    cout<<max(s[0],s[1])<<' '<<min(s[0],s[1])<<endl;
}

int main(){
    cin>>n;
    for (int i=1;i<=n;++i) cin>>a[i];
    if (n&1) fuck1();
    else fuck0();
}

Measured memory_bytes: 2560
import sys
input = sys.stdin.readline

def main():
    def com(com_n, com_r):
        return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md

    md = 10 ** 9 + 7
    n, m = map(int, input().split())
    aa = list(map(lambda x: int(x) - 1, input().split()))
    n2 = 2 ** n

    # combinationの準備
    n_max = n2
    fac = [1]
    inv = [1] * (n_max + 1)
    k_fac_inv = 1
    for i in range(1, n_max + 1):
        k_fac_inv = k_fac_inv * i % md
        fac.append(k_fac_inv)
    k_fac_inv = pow(k_fac_inv, md - 2, md)
    for i in range(n_max, 1, -1):
        inv[i] = k_fac_inv
        k_fac_inv = k_fac_inv * i % md

    dp = [[0] * n2 for _ in range(m + 1)]
    dp[0][0] = 1
    for i in range(m):
        a = aa[m - 1 - i]
        for b in range(n2):
            pre = dp[i][b]
            if pre == 0: continue
            dp[i + 1][b] = (dp[i + 1][b] + pre) % md
            k = 1
            for _ in range(n):
                if b & k == 0 and n2 - a - b >= k:
                    nb = b | k
                    dp[i + 1][nb] = (dp[i + 1][nb] + pre * com(n2 - 1 - a - b, k - 1)) % md
                k <<= 1
    for b in range(n2):
        k = 1
        p = n2 - 1 - b
        for _ in range(n):
            if b & k == 0:
                dp[m][b] = dp[m][b] * com(p, k) % md
                p -= k
            k <<= 1
    ans = 0
    for b in range(n2):
        coff = -1 if bin(b).count("1") % 2 else 1
        ans = ans + coff * dp[m][b]
    k = 1
    for _ in range(n - 1):
        k <<= 1
        ans = ans * fac[k] % md
    ans = ans * n2 % md
    print(ans)

main()


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int n;
	cin >> n;
	if(n % 2 == 0) cout << n << endl;
	else cout << 2*n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S, T;
  std::cin >> S >> T;

  i64 answer = 0;
  for (auto it1 = S.begin(), it2 = T.begin(); it1 != S.end() && it2 != T.end(); ++it1, ++it2) {
    if (*it1 == *it2) ++answer;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
using namespace std;
#define MAX_V 100000

int represent[MAX_V];
int status[MAX_V];

int findRepresent(int x)
{
    if (represent[x] == x) {
        return x;
    } else {
        represent[x] = findRepresent(represent[x]);
        return represent[x];
    }
}

void unite(int x, int y)
{
    x = findRepresent(x);
    y = findRepresent(y);
    if (x == y)
        return;
    if (status[x] < status[y])
        swap(x, y);
    assert(status[x] >= status[y]);
    represent[y] = x;
    if (status[x] == status[y])
        status[x]++;
}

bool same(int x, int y)
{
    return (findRepresent(x) == findRepresent(y));
}

int main()
{
    for (int i = 0; i < MAX_V; ++i) {
        represent[i] = i;
        status[i] = 0;
    }

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        unite(a, b);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int from, to;
        cin >> from >> to;
        cout << (same(from, to)? "yes" : "no") << '\n';
    }
    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define mkp make_pair
const ll H1=257,H2=114,M1=1e9+7,M2=19260817;
int n,T;
char c[1000004];
bool ok[1000004][26];
string s[200004];
int p[200004];
map<pii,int>mp;
ll ans=0;
bool cmp(int a,int b){
	return s[a].size()>s[b].size();
}
void reads(string &S){
	S="";register char ch=getchar();
	for(;ch<'a'||ch>'z';ch=getchar());
	for(;ch>='a'&&ch<='z';S+=ch,ch=getchar());
}
int main(){
	cin>>T;
	for(int i=0;i<T;i++)reads(s[i]),p[i]=i;
	sort(p,p+T,cmp); 
	while(T>0){
		T--;
		n=s[p[T]].size();
		for(int i=0;i<n;i++)c[n-i-1]=s[p[T]][i];
		for(int i=0;i<26;i++)ok[n][i]=0;
		for(int i=n-1;i>=0;i--){
			for(int j=0;j<26;j++)ok[i][j]=ok[i+1][j];
			ok[i][c[i]-'a']=1;
		}
		ll r1=0,r2=0;
		for(int i=0;i<n-1;i++){
			int msk=mp[mkp(r1,r2)];
			for(int j=0;j<26;j++)if((msk&(1<<j))>0&&ok[i][j])ans++;
			r1=(r1*H1+c[i])%M1,r2=(r2*H2+c[i])%M2;
		}
		mp[mkp(r1,r2)]|=(1<<(c[n-1]-'a'));
	}
	cout<<ans;
}

Measured memory_bytes: 97604
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
ru = []
ld = []
for _ in range(n):
    x, y = map(int, input().split())
    ru.append(x + y)
    ld.append(x - y)

ru.sort()
ld.sort()
ans = 0
ans = max(ru[-1] - ru[0], ans)
ans = max(ld[-1] - ld[0], ans)

print(ans)

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

public class Main{
      static int N=200+10;
      static int f[]=new int [N];
      static char b[]=new char[N];
      static void getFail(char b[],int m) {
          int j=0;
          f[0]=f[1]=0;
          for(int i=2;i<=m;i++) {
              while(j>0&&b[j+1]!=b[i]) j=f[j];
              if(b[j+1]==b[i]) j++;
              f[i]=j;
          }
      }
      public static void main(String[] args){
          InputReader in=new InputReader(System.in);
          //Scanner sc=new Scanner(new InputStreamReader(System.in));
          PrintWriter out=new PrintWriter(System.out);
    	  int n=in.nextInt();
          String s1=in.next(),str=in.next();
          int cnt=0;
          for(int i=0;i<n;i++) b[++cnt]=str.charAt(i);
          for(int i=0;i<n;i++) b[++cnt]=s1.charAt(i);
          getFail(b,cnt);
          int len=Math.min(f[cnt],Math.min(n, n));
          out.println(2*n-len);
          out.flush();
      }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    string W;
    cin >> W;
    string T;
    int num = 0;

    while(true){
        cin >> T;
        if(T == "END_OF_TEXT") break;
        transform(T.begin(), T.end(), T.begin(), ::tolower);
        if(T == W) ++num;
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 3164
import java.util.Scanner;

/**
 * WaitForSunday
 */
class Main {

    public static void main(String[] args) {
        java.util.Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int DayToNextSunday = 0 ;
        switch (s) {
            case "MON": 
                    DayToNextSunday = 6;
                break;
            case "TUE":
                    DayToNextSunday = 5;
                break;
            case "WED":
                    DayToNextSunday = 4;
                break;
            case "THU":
                    DayToNextSunday = 3;
                break;
            case "FRI":
                    DayToNextSunday = 2;
                break;
            case "SAT":
                    DayToNextSunday = 1;
                break;
            case "SUN":
                DayToNextSunday = 7;
            break;
            default:
                break;
        }
        System.out.println(DayToNextSunday);
    }
}

Measured memory_bytes: 20692
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class DFlippingSigns {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> A(N);
    int minus = 0;
    rep(i, N) {
      cin >> A[i];
      if (A[i] < 0) minus++;
      A[i] = abs(A[i]);
    }
    if (minus % 2) {
      cout << accumulate(ALL(A), 0LL) - 2 * MIN(A) << endl;
    } else {
      cout << accumulate(ALL(A), 0LL) << endl;
    }
  }
};


signed main() {
  DFlippingSigns solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main()
{
    vector<int> v;
    int n;
    cin >> n;

    while (n--)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int q;
    cin >> q;

    while (q--)
    {
        int k;
        cin >> k;
        cout << binary_search(v.begin(), v.end(), k) << endl;
    }
    return 0;
}


Measured memory_bytes: 3436
//agrawal117
//chahatagrawal117
#include <bits/stdc++.h>
#pragma GCC optimize "O3"
#define endl '\n'
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,a,b;
    cin>>n>>a>>b;
    ll val=b-a-1;
    if(val%2==1){
        ll ans=val/2;
        ans++;
        cout<<ans<<endl;
    }
    else{
        ll x=a-1;
        ll ans=x;
        ll y= b-x;
        ll fin=n+1;
        ans++;
        y--;
        if(y==1){
            fin=min(fin,ans);
        }
        else{
            ll fck=y-2;
            ans+=(fck/2);
            ans++;
            fin=min(fin,ans);
        }
        x=n-b;
         y=a+x;
        ans=x;
        ans++;
        y++;
        if(y==n){
            fin=min(fin,ans);
        }
        else{
            ll fck=n-y-1;
            ans+=(fck/2);
            ans++;
            fin=min(fin,ans);
        }
        cout<<fin<<endl;
    }
}
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define codefor int test;cin>>test;while(test--)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;

int main(){
    int h,w,k,kuro=0;
    cin>>h>>w>>k;
    char c[h][w];
    rep(y,h){
        rep(x,w){
            cin>>c[y][x];
            if(c[y][x]=='#')kuro++;
        }
    }
    int def=0,ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            def=0;
            bitset<6> y1(i);
            bitset<6> x1(j);
            rep(y,h){
                rep(x,w){
                    if(!(x1.test(x))&&!(y1.test(y))&&c[y][x]=='#')def++;
                }
            }
            if(def==k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
n = list(map(int, input().split()))
f = 0
for i in n:
    if i == 1:
        f += 1
    elif i == 7:
        f += 10
    elif i == 9:
        f += 100
    elif i == 4:
        f += 1000
print("YES" if f == 1111 else "NO")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
void solve(){
  int n;
  cin>>n;
  vector<double>t(n+1),v(n+1);
  vector<double>S;
  double sum_t=0;
  rep(i,n){
    cin>>t[i+1];
    t[i+1]+=t[i];
  }
  sum_t=t.back();
  rep(i,n){
    cin>>v[i];
  }
  auto func=[&](double cur,double left,double right,double velocity)->double{//最大の速度を返す
    if(left<=cur&&cur<=right)return velocity;
    else if(right<cur)return velocity+(cur-right);
    else return velocity+(left-cur);
  };
  for(double i=0;i<=sum_t;i+=0.5){
    double vv=1e9;
    rep(j,n){
      chmin(vv,func(i,t[j],t[j+1],v[j]));
    }
    chmin(vv,i);//始点からの影響
    chmin(vv,sum_t-i);//終点からの影響
    S.pb(vv);
  }
  double ans=0;
  rep(i,S.size()-1){
    ans+=(S[i]+S[i+1])*0.25;
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 892
import math
def ccc(a, b):

    for i in range(1, 100000):
        an = math.floor(i * 0.08)
        bn = math.floor(i * 0.1)
        if an == a and bn == b:
            return i
    return "-1"

def main():
    a , b = map(int , input().split())
    print(ccc(a , b))

if __name__ == '__main__':
    main()

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

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


Measured memory_bytes: 256