akhauriyash/Code-Regression huggingface dataset:
import sys
from cmath import rect
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

eps = 1e-9

@njit((numba.complex128, numba.float64) * 2, cache=True)
def cross_circles(c1, r1, c2, r2):
    d = abs(c1 - c2)
    if d <= abs(r1 - r2) or r1 + r2 <= d:
        return None
    cos_theta = (r1 * r1 + d * d - r2 * r2) / (2 * r1 * d)
    theta = np.arccos(cos_theta)
    z1 = (c2 - c1) * rect(r1 / d, theta)
    z2 = (c2 - c1) * rect(r1 / d, -theta)
    return (c1 + z1, c1 + z2)

@njit
def test(Z, C, t):
    R = t / C
    cand = list(Z)
    for j in range(len(Z)):
        for i in range(j):
            points = cross_circles(Z[i], R[i], Z[j], R[j])
            if points is not None:
                for p in points:
                    cand.append(p)
    cand = np.array(cand)
    cnt = np.zeros(len(cand), np.int64)
    for i in range(len(Z)):
        cnt += np.abs(cand - Z[i]) <= R[i] + eps
    return np.any(cnt >= K)

N, K = map(int, readline().split())
nums = np.array(read().split(), np.float64)

Z = nums[::3] + 1j * nums[1::3]
C = nums[2::3]

l = 0
r = 10**9
for _ in range(100):
    m = (l + r) / 2
    if test(Z, C, m):
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 118568
package main

import (
	"fmt"
)

func main() {
	var n1, n2, dig, sum int
	fmt.Scanf("%d", &n1)
	n2 = n1
	for i := 0; 0 < n2; i++ {
		dig = n2 % 10
		sum = sum + dig
		n2 = n2 / 10

	}
	canBreak := "No"
	if n1%sum == 0 {
		canBreak = "Yes"
	}
	fmt.Printf("%s", canBreak)
}

Measured memory_bytes: 1832
# -*- coding: utf-8 -*-

N, M, C = map(int, input().split())
B = [int(b) for b in input().split()]
res = 0
for i in range(N):
    A = [int(a) for a in input().split()]
    s = sum([a*b for a, b in zip(A, B)])+C
    if s > 0:
        res += 1
print(res)


Measured memory_bytes: 3060
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  string s; cin>>s;
  if(s[2]==s[3] && s[4]==s[5]){
    cout<<"Yes"; return;
  }
  cout<<"No";
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, W;
    cin >> N >> W;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    rep(i, N) {
        P p = items[i];
        rep(j, W + 1) {
            if (j - p.second >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - p.second] + p.first);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << '\n';
}

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



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

double memo [101][102];
double mp[101][101];
double ans;
int n,m;
int cnt;

void saiki(double seki,double pseki,int mae,int kai) {
  //  cout <<"seki="<<seki<<" mae="<<mae<<" kai="<<kai<<endl;
  cnt++;
  
  if(kai == m && ans < seki) ans = seki;
  if(kai == m && mae != -1) memo[kai][mae] = 1;
  
  if(kai < m) {
    for(int i=1;i<=n;i++) {
      if(memo[kai+1][i] == -1) {
	saiki(seki*mp[mae][i],seki,i,kai+1);
	if(memo[kai][mae] < memo[kai+1][i]*mp[mae][i]) memo[kai][mae] = memo[kai+1][i]*mp[mae][i];
      }
      else {
	if(memo[kai][mae] < memo[kai+1][i]*mp[mae][i])memo[kai][mae] = memo[kai+1][i]*mp[mae][i];
	saiki(memo[kai][mae]*seki,-1,-1,m);
      }
    }
  }
}

int main(){
  
  while(1){
    cin >> n>> m;
    if(n == 0 && m == 0) break;
    
    for(int i=0;i<=n;i++)
      for(int j=0;j<=n;j++)
	if(i == 0 || j == 0) mp[i][j] = 1;
	else cin >> mp[i][j];

    
    for(int i=0;i<=m;i++)
      for(int j=0;j<=n;j++)
	memo[i][j] = -1;

    ans = 0;
    
    int ans2=0;
    for(int i=1;i<=n;i++) {
      saiki(1,1,i,1);
      for(int j=0;j<=n;j++){
	if(ans2 < memo[1][i]) ans2 = memo[1][i];
	memo[1][i] = memo[2][i]= -1;
      }
    } 
    

    
    //    cout << ans2 << endl;
    printf("%.2f\n",ans);
    //cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

import heapq

def solve():
    n, m = MI()
    A = LI()

    A = list(map(lambda x: -x, A))

    heapq.heapify(A)
    # print(A)

    for i in range(m):
        x = heapq.heappop(A)
        heapq.heappush(A, x / 2)

    A = list(map(lambda x: int(-x), A))
    print(sum(A))
if __name__ == '__main__':
    solve()


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){ 
  ll A,B;
  cin >> A >> B;
  
  if(max(A+B,A*B) > A-B) cout << max(A+B,A*B) << endl;
  else cout << A-B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m), sa(n), sb(m);;
	rep(i, n) {
		cin >> a[i];
		if (i == 0) sa[i] = a[i];
		else sa[i] = sa[i - 1] + a[i];
	}
	rep(i, m) {
		cin >> b[i];
		if (i == 0) sb[i] = b[i];
		else sb[i] = sb[i - 1] + b[i];
	}

	ll ans = 0;
	ll ca = 0;
	ll cb = 0;

	while (1) {
		cb++;

		if (cb == m + 1) {
			cb--;
			int time = sb[m - 1];

			while(1){
				ca++;
				if (ca == n + 1) {
					ans = max(ans, n + m);
					break;
				}
				if (time + sa[ca - 1] <= k) {
					ans = max(ans,m + ca);
				}
				else {
					break;
				}
			}
			break;
		}

		if (sb[cb - 1] <= k) {
			ans = max(ans,cb);
		}
		else {
			break;
		}
	}

	ca = 0;
	int flg = 1;

	while (1) {
		ca++;
		if (ca >= n + 1 || cb==0) {
			break;
		}

		while (sa[ca-1] + sb[cb-1] > k) {
			cb--;
			if (cb == 0) {
				flg = 0;
				break;
			}
		}

		if (flg == 0) {
			break;
		}

		ans = max(ans, ca + cb);
	}

	rep(i, n) {
		if (sa[i] <= k) {
			ans = max(ans, (ll)i + 1);
		}
	}


	////////////////////////////////
	ca = 0;
	cb = 0;
	while (1) {
		ca++;

		if (ca == n + 1) {
			ca--;
			int time = sa[n - 1];

			while (1) {
				cb++;
				if (cb == m + 1) {
					ans = max(ans, n + m);
					break;
				}
				if (time + sb[cb - 1] <= k) {
					ans = max(ans,n + cb);
				}
				else {
					break;
				}
			}
			break;
		}

		if (sa[ca - 1] <= k) {
			ans = max(ca,ans);
		}
		else {
			break;
		}
	}

	cb = 0;
	flg = 1;

	while (1) {
		cb++;
		if (cb >= m + 1 || ca == 0) {
			break;
		}

		while (sb[cb - 1] + sa[ca - 1] > k) {
			ca--;
			if (ca == 0) {
				flg = 0;
				break;
			}
		}

		if (flg == 0) {
			break;
		}

		ans = max(ans, ca + cb);
	}

	rep(i, m) {
		if (sb[i] <= k) {
			ans = max(ans, (ll)i + 1);
		}
	}



	cout << ans << endl;


}






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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s , t ;
  cin >> s >> t ;
  string S = s+s ;
  string ANS = "No";
  
 rep(i,s.size()){
   bool ans = true;
   int now = 0;
   for(int j=i;j<i+s.size();j++){
     if(S.at(j) !=t.at(now)){
       ans = false ;
     }
     now ++ ;
   }
  if(ans)  ANS = "Yes";
 }
  
 cout << ANS ;
}
 

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

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))


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



int main(void)
{
	//変数の宣言
	int n;
	int m[40];
	int mtemp[40];
	static int a[100010][40];
	int b[100010];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	llong int ans=0;
	int count=0;
	int sum=0;
	llong int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %lld",&n,&temp);
	
	for(i=0;i<30;i++){
		if(temp!=0){
			m[i]=(int)(temp%2);
			temp=temp/2;
		}else{
			m[i]=0;
		}
	}
	
	
	for(i=0;i<n;i++){
		scanf("%lld %d",&temp,&b[i]);
		for(j=0;j<30;j++){
			if(temp!=0){
				a[i][j]=(int)(temp%2);
				temp=temp/2;
			}else{
				a[i][j]=0;
			}
		}
	}
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<30;i++){
		if(i==0){
			for(j=0;j<30;j++){
				mtemp[j]=m[j];
			}
		}else{
			if(m[i]==1){
				mtemp[i]=0;
				for(j=0;j<i;j++){
					mtemp[j]=1;
				}
			}else{
				mtemp[i]=0;
				for(j=0;j<i;j++){
					mtemp[j]=m[j];
				}
			}
			for(j=i+1;j<30;j++){
				mtemp[j]=m[j];
			}
		}
		
		temp=0;
		for(j=0;j<n;j++){
			flag=1;
			for(k=0;k<30;k++){
				if(a[j][k]>mtemp[k]) flag=0;
			}
			if(flag==1){
				temp=temp+b[j];
			}
		}
		if(ans<temp) ans=temp;
	}
	
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%lld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
int n;
struct node
{
	int num,t;
}a[100010];
inline bool cmp(node x,node y)
{
	return x.num<y.num;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		a[i].t=i,cin>>a[i].num;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		cout<<a[i].t<<' ';
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){
    int q;
    cin>>q;
    auto p=prime_table(100000);
    int goodnum[100001]={};
    rep(i,100001){
        if(i%2==0)continue;
        if(p[i]&p[(i+1)/2]){
            goodnum[i]=1;
        }
    }
    rep(i,100000) goodnum[i+1]+=goodnum[i];
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<goodnum[r]-goodnum[l-1]<<endl;
    }
}


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

using namespace std;

typedef long long ll;

int main(){
  int a, b, x;
  double z = 0.0;
  cin >> a >> b >> x;
  if (a*a*b/2.0 >= x){
    z = 2.0*x/(a*b);
    cout << setprecision(11) << atan(b/z)*(180/acos(-1)) << endl;
  }
  else{
    z = 2.0*x/(a*a)-b;
    cout << setprecision(11) << atan((b-z)/a)*(180/acos(-1)) << endl;
  }
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main() {
    int n,m;
    cin>>n>>m;
    vector <vector <int>> answer(n,vector<int>(m));
    vector <vector <int>> ans(n,vector<int>(m,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char input;
            cin>>input;
            if(input=='.')answer[i][j]=0;
            else answer[i][j]=-1;
        }
    }
    ans[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(answer[i][j]==-1){
                ans[i][j]=0;
                continue;
            }
            if(i==0 && j==0)continue;
            if(i==0){
                if(answer[i][j-1]==-1)ans[i][j]=0;
                else ans[i][j]=ans[i][j-1];
                continue;
            }
            if(j==0){
                if(answer[i-1][j]==-1)ans[i-1][j]=0;
                else ans[i][j]=ans[i-1][j];
                continue;
            }
            ans[i][j]=(ans[i][j-1]%mod+ans[i-1][j]%mod)%mod;
        }
    }cout<<ans[n-1][m-1]<<endl;
    
    
}


Measured memory_bytes: 11404
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;


#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;

vector<string> wrap(vector<string> s,char c){
    int R=s.size();
    int C=s[0].size();
    vector<string> res(R+2,string(C+2,c));
    REP(i,R)REP(j,C)res[i+1][j+1]=s[i][j];
    return res;
}
int f(int a,int b){
    return (a+b-1)/b;
}
int dr[]={0,1,0,-1};
int dc[]={1,0,-1,0};
typedef pair<int,int> P;
int main(){
    int R,C,K;
    cin>>R>>C>>K;
    vector<string> S(R);
    cin>>S;
    S=wrap(S,'#');
    R+=2;C+=2;
    int sr,sc;
    REP(i,R)REP(j,C)if(S[i][j]=='S')sr=i,sc=j;
    VV cost(R,V(C,1145141919));
    
    int res=114514;
    queue<P> que;
    que.push(P(sr,sc));
    cost[sr][sc]=0;

    while(que.size()){
        sr=que.front().fi;
        sc=que.front().se;
        
        que.pop();

        REP(i,4){
            int nr=sr+dr[i];
            int nc=sc+dc[i];
            int ncost=cost[sr][sc]+1;
            if(S[nr][nc]!='#'&&chmin(cost[nr][nc],ncost)){
                que.push(P(nr,nc));
            }
        }
    }
    R--;C--;
    FOR(i,1,R)
        FOR(j,1,C)
        if(cost[i][j]<=K){
            chmin(res,1+f(min({i-1,j-1,R-i-1,C-j-1}),K));
        }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
n = int(input())
min_list=[0]*n
max_list=[0]*n
result = 0

for i in range(n):
    a, b = map(int, input().split())
    min_list[i] = a
    max_list[i] = b

min_list.sort()
max_list.sort()

# print(min_list)
# print(max_list)
if n%2 == 0:
    center_idx = n // 2
#    print(center_idx)
    result = max_list[center_idx] + max_list[center_idx-1] - min_list[center_idx] - min_list[center_idx-1] + 1
else:
    center_idx = n // 2
#    print(center_idx)
    result = max_list[center_idx] - min_list[center_idx] + 1
print(result)

Measured memory_bytes: 75592
let rec kn a k = 
        if a <= 0 || k <= 0 then 
                0
        else if a < k then
                a
        else
                k


let () = Scanf.scanf "%d %d %d %d" (
fun a b c k -> 
        let an = kn a k in
        let bn = kn b (k - an) in
        let cn = kn c (k - an - bn) in
        an - cn
) |> Printf.printf "%d\n"

Measured memory_bytes: 3844
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
  	double A, B;
    double H, M;
  	cin >> A >> B >> H >> M;
  	double omega = M_PI / (12*30);
  	double omega2 = M_PI / 30;
  	double l_theta = omega*(H*60+M);
    double s_theta = omega2*M;
  	double theta = fabs(l_theta-s_theta);
  	double ans = sqrt(A*A + B*B - 2*A*B*cos(theta));
	printf("%.10f",ans);
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  string s = readString();
  int cnt = 0;
  REP(i, 3) {
    if (s[i] == 'o') cnt++;
  }
  print(700 + (cnt * 100));
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<string> s(N); 
    for(int i = 0;i<N;i++){
        cin >> s.at(i);
    }
    int M;
    cin >> M;
    vector<string> t(M); 
    for(int i = 0;i<M;i++){
        cin >> t.at(i);
    }
    int money = 0;
    int blue=1,red =0;
    for(int i =0;i<N;i++){
        blue = 1,red = 0;
        for(int k = 0;k<M;k++){
            if(s[i] == t[k]){
                red++;
            }
        }
        for(int j = i+1;j<N;j++){
            if(s[i]==s[j]){
                blue ++;
            }

        }
        if(blue-red>money){
            money = blue -red;
        }
    }
    cout << money << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100001];
bool util(int arr[], int n, int k){
    if(dp[k] != -1) return dp[k];
    bool flag = false;
    for(int i=0;i<n;i++){
        if(k - arr[i] >= 0){
            bool next = util(arr, n, k - arr[i]);
            if(next == false){
                flag = true;
                break;
            }
        }
    }
    dp[k] = flag;
    return flag;
}
int main(){
    int n, k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp, -1, sizeof(dp));
    bool res = util(arr, n, k);
    if(res){
        cout<<"First";
    }else cout<<"Second";
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  ll N, K; cin >> N >> K;
  map<int, ll> mp;
  for (int i = 0; i < N; ++i) {
    ll a, b; cin >> a >> b;
    mp[a] += b;
  }

  ll num = 0;
  for (auto v : mp) {
    num += v.second;
    if (K <= num) {
      cout << v.first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4224
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,q,i,ansv
    integer(int32), allocatable:: a(:),b(:),c(:),d(:), ij(:,:,:),ans(:)

    read*, n,m,q
    allocate(a(q),b(q),c(q),d(q),ans(n),ij(n,n,2))
    ij(:,:,:) = 0
    do i=1,q
        read*, a(i),b(i),c(i),d(i)
        ij(a(i),b(i),1) = c(i)
        ij(a(i),b(i),2) = d(i)
    end do

    ans(:) = 1
    ansv=0

    do
        ansv = max(calc_sum(),ansv)
        if (next()) exit
    end do

    print'(i0)', ansv
contains
    function calc_sum() result(ret)
        integer(int32):: ret
        integer(int32):: i

        ret=0
        do i=1,q
            if (ans(b(i))-ans(a(i)) == c(i)) ret=ret+d(i)
        end do
    end function

    
    function next() result(ret)
        integer(int32):: i 
        logical:: ret

        ret = .false.
        i=n
        do while(ans(i) >= m)
            i=i-1
            if (i==0) then
                ret = .true.
                return
            end if
        end do
        ans(i:n) = ans(i)+1
    end function
end program name

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

int cnt[26];

int main() {

	string S; cin >> S;
	if (S.size() < 26) {
		for (int i = 0; i < S.size(); i++) {
			cnt[S[i] - 'a']++;
		}
		for (int i = 0; i < 26; i++) {
			if (cnt[i] == 0) {
				S.push_back('a' + i);
				cout << S << endl;
				return 0;
			}
		}
	}
	else {

		for (int i = S.size()-1; i >= 0; i--) {
			for (int j = S[i] - 'a'+1; j < 26; j++) {
				if (cnt[j]) {
					S[i] = 'a' + j;
					cout << S << endl;
					return 0;
				}
			}
			cnt[S[i] - 'a']++;
			S.pop_back();
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;

	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(" ");
			int n = Integer.parseInt(nico[0]);
			int m = Integer.parseInt(nico[1]);
			if ((n == 0) && (m == 0)) break;
			
			int[] num = new int[n];
			for (int i = 0; i < n; i++) {
				num[i] = 0;
			}
			
			int cnt = 0;
			int tmp = 0;
			while (cnt < n) {
				for (int i = 0; i < n; i++) {
					if (num[i] != 0) continue;
					tmp++;
					
					if (tmp == m) {
						cnt++;
						num[i] = cnt;
						
						if (cnt == n) System.out.println(i + 1);
						
						tmp = 0;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 27012
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n,k;
  cin>>n>>k;
  long long int sum=0;
  for(long long int i=k;i<=n+1;i++){
    sum +=i*(n-i+1)+1;
  }
  cout<<sum%(1000000007);
 
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	 public static void main(String[] args){
		 Scanner sc = new Scanner(System.in);
		 int num[]=new int[3];
		 int count[]= {0,0};
		 for(int i=0;i<3;i++) {
			num[i] = sc.nextInt();
		 }
		 for(int i=0;i<3;i++) {
			 if(num[i]==5)
				 count[0]++;
			 else if(num[i]==7)
				 count[1]++;
		 }
		 if(count[0]==2&&count[1]==1)
			 System.out.println("YES");
		 else
			 System.out.println("NO");
	     sc.close();
	 }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int a;
	set<int>s;
	for(int i=0;i<3;i++)
	{
		cin>>a;
		s.insert(a);
	}
	cout<<s.size()<<endl;
	return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Zabuton
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 5000;
const long long LINF = 1LL << 60;

/* typedef */

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

/* global variables */

pii hps[MAX_N];
ll dp[MAX_N + 1][MAX_N + 1];

/* subroutines */

inline void setmin(ll &a, ll b) { if (a > b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int hi, pi;
    scanf("%d%d", &hi, &pi);
    hps[i] = pii(hi + pi, hi);
  }
  sort(hps, hps + n);

  for (int i = 0; i <= n; i++) fill(dp[i], dp[i] + n + 1, LINF);
  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    int &hi = hps[i].second, pi = hps[i].first - hi;
    for (int j = 0; j <= i; j++) {
      setmin(dp[i + 1][j], dp[i][j]);
      if (dp[i][j] <= hi)
	setmin(dp[i + 1][j + 1], dp[i][j] + pi);
    }
  }

  int maxj = 0;
  for (int j = 0; j <= n; j++)
    if (dp[n][j] < LINF) maxj = j;
  printf("%d\n", maxj);
  return 0;
}


Measured memory_bytes: 195712
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    def innerLoop(j: Int, p: Int): Unit = {
      notPrime(j)
      if(j + p <= top)innerLoop(j + p, p)
    }

    def loop(i: Int): Unit = {
      val p = 2 * i + 3
      if(isPrime(i))innerLoop((p * p - 3) / 2, p)
      if(i < sqrtLimit)loop(i + 1)
    }

    def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      //loop(0)
      for{
        i <- 0 to sqrtLimit
        if isPrime(i)
        j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))
      } notPrime(j)

      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
 
int main()
{
	bool a[31]={false};
	int n;
	for(int i=0;i<28;i++){
		cin>>n;
		a[n]=true;
	}
	for(int i=1;i<31;i++){
		if(a[i]==false) cout<<i<<endl;
	}
	return 0;
}

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

class Program {
	static void Main(string[] args) {
		new Calc().calc();
	}
	public class Calc {
		public Calc() { }
		public void calc() {
			List<int> list = new List<int>();
			int n = ReadLine<int>();
			while (n!=0) {
				n = 1000 - n;
				int sum = n.ToString().Select(_ => int.Parse(_ + "")).Select(_ => _ % 5 + _ / 5).Sum();
				list.Add(sum);
				n = ReadLine<int>();
			}
			foreach (var item in list) {
				Console.WriteLine(item);
			}
			return;
		}
	}

	public static T ReadLine<T>() {
		return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
	}
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int x;
	cin >> x;

	for(int i = -118; i <= 119; i++){
		for(int j = -119; j <= 118; j++){
			int res = pow(i, 5) - pow(j, 5);
			if(res == x){
				printf("%d %d\n", i, j);
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n, x; cin >> n >> x;
  ll ans = n;
  n = n - x;
  while(n > 0 && x > 0) {
    // cout << ans << ":" << n << ":" << x << endl;
    if(n > x) {
      ans += x * 2 * (n/x);
      n = n % x;
    } else if (n < x) {
      ans += n * 2 * (x/n);
      x = x % n;
    } else {
      ans += 2 * n;
      n = 0;
    }
  }
  ans -= n + x;
  cout << ans << endl;
}


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

int main(){
  ll n,k,ans,i;
  cin >> n >> k;
  ll p[n];
  for(i=0;i<n;i++){
    cin >> p[i];
  }
  sort(p,p+n);
  ans=0;
  for(i=0;i<k;i++){
    ans+=p[i];
  }
  cout << ans;
}

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

int N,M;

int v[100001];
vector<pair<int,int>>e[100001];

void dfs(int i,int x){
	v[i]=x;
	for(auto a:e[i]){
		if(v[a.first]){
			if(v[i]+a.second!=v[a.first]){
				cout<<"No";
				exit(0);
			}
		}else{
			dfs(a.first,v[i]+a.second);
		}
	}
}

main(){
	cin>>N>>M;
	for(int i=0;i<M;++i){
		int L,R,D;
		cin>>L>>R>>D;
		e[L].push_back({R,D});
		e[R].push_back({L,-D});
	}
	for(int i=1;i<=N;++i){
		if(!v[i]){
			dfs(i,(int)1e9);
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 11008
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int l=s.length(), co=0, cx=0;
  for(int i=0;i<l;++i)
  {
    if(s[i]=='o')
      co++;
    else
      cx++;
  }
  if(cx<8)
    cout<<"YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
int n;
int main()
{
	scanf("%d",&n);
	if(n%10==7||n/10%10==7||n/100==7)printf("Yes");
	else printf("No");
	
	return 0;
} 

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,N;
    cin >> H >> N;
    int sum = 0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        sum += a;
    }
    cout << (sum>=H? "Yes":"No") << endl;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 20000005;
bool isPrime[MAXN];
vector<int> pr;
vector<pair<int,int>> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {
            if(!pr.empty())
            {
                if(i-pr.back()==2)
                {
                    ans.push_back({pr.back(),i});
                }
            }
            pr.push_back(i);

        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main()
{
    ll n;
    cin>>n;
    string h;
    while(n>0){
        int mod=n%26;
        if(mod==0){
            h+='z';
        }
        else{
            h+=('a' + (mod-1));
        }
        n--;
        n/=26;

    }

    reverse(h.begin(),h.end());
    cout<<h<<endl;
    return 0;
}


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

int main(){
    int N;cin>>N;
    map<int ,int> a;
    set<int> b;
    for(int i=0,p;i<N;i++){
        cin>>p;
        if(a.count(p))a.at(p)++;
        else a.insert(make_pair(p,1));
        b.insert(p);
    }
    int ans=0;
    auto itr=b.begin();
    while(itr!=b.end()){
        if(a[*itr]>*itr)ans+=a[*itr]-*itr;
        else if(a[*itr]<*itr)ans+=a[*itr];
        itr++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9216
import math
N, H = map(int, input().split())
countA=0
countB=0
count=0
flag=True
maxA=0
maxB=0
listA=[0 for j in range(N)]
listB=[0 for j in range(N)]
bigB=[]
for i in range(N):
    A, B = map(int, input().split())
    listA[i]=A
    listB[i]=B
    if maxA<A:
        maxA=A
        maxAindex=i
        maxB=B

listB.sort()
listB.reverse()

for i in range(N):
    if maxA<=listB[i]:
        countB+=listB[i]
        count+=1
    if countB>=H:
        print(count)
        flag=False
        break

if flag:
    print(count+math.ceil((H-countB)/maxA))

    

Measured memory_bytes: 11364
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    string s; cin >> s;
    int x = stoi(s.substr(0, 2));
    int y = stoi(s.substr(2, 2));

    bool flag1 = (1 <= x && x <= 12 && 0 <= y);
    bool flag2 = (1 <= y && y <= 12 && 0 <= x);
    string ans= "";
    if(flag1 && flag2) ans = "AMBIGUOUS";
    else if(flag1) ans = "MMYY";
    else if(flag2) ans = "YYMM";
    else ans = "NA";
    cout << ans << endl;
    return 0;
}



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



int main() {

    map<char,char> m;
    m['A']='T';
    m['T']='A';
    m['G']='C';
    m['C']='G';
    char c;cin>>c;
    cout<<m[c]<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai acos(-1)
#define keta(n) cout << fixed << setprecision((n))
#define ll long long
int main()
{
  double a, b, c, d2, d;
  double s, l, h;
  cin >> a >> b >> c;
  
  s = 0.5 * a * b * sin(pai / 180 * c);
  d2 = b * b + a * a - 2 * a * b * cos(pai / 180 * c);
  d = sqrt(d2);
  l = a + b + d;
  h = 2 * s / a;
  keta(5);
  cout << s << " " << l << " " << h << endl;
}




Measured memory_bytes: 3564
#include <iostream>

using namespace std;

const int MAXN = 105;
const int MAXV = 1e3 + 5;
long long dp[MAXN][MAXN * MAXV];
int n, x;
int a[MAXN];
long long w[MAXN];

int main()
{
    cin >> n >> x;
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> a[i];
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < MAXN * MAXV; j++){
            if(i == 0){
                if(j != 0){
                    dp[i][j] = 1e18;
                }
                continue;
            }
            dp[i][j] = dp[i - 1][j];
            if(j < a[i]){
                dp[i][j] = min(dp[i][j], w[i]);
            }
            else{
                dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i]] + w[i]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < MAXN * MAXV; i++){
        if(dp[n][i] <= x){
            ans = i;
        }
    }
    cout << ans;
}


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

typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = (ll)(1+n)*n/2;
	ll num1 = n / 3;
	ans -= 3 * (1+num1)*num1/2;
	num1 = n / 5;
	ans -= 5 * (1+num1)*num1/2;
	num1 = n / 15;
	ans += 15 * (1+num1)*num1/2;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3640
from collections import deque

def main():
    h, w = map(int, input().split())
    start_h, start_w = map(lambda x: int(x)+1, input().split())
    goal_h, goal_w = map(lambda x: int(x)+1, input().split())

    s = ["#"*(w+4)]
    s.append("#"*(w+4))
    for _ in range(h):
        s.append("##" + input() + "##")
    s.append("#"*(w+4))
    s.append("#"*(w+4))

    ans = [[-1]*(w+4) for _ in range(h+4)]
    for i in range(h+4):
        for j in range(w+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ans[start_h][start_w] = 0

    move1 = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    move2 = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),(0, -2), (0, -1), (0, 0), (0, 1), (0, 2),(1, -2), (1, -1), (1, 0), (1, 1), (1, 2),(2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

    yet = deque([(start_h, start_w)])
    done = deque()

    while yet:
        x1, y1 = yet.popleft()
        done.append((x1, y1))
        for (p, q) in move1:
            v1, v2 = x1+p, y1+q
            if ans[v1][v2] == -1: #"."でまだ辿り着いていないマス
                yet.append((v1, v2))
                ans[v1][v2] = ans[x1][y1]

        if len(yet) == 0:
            while done:
                x2, y2 = done.popleft()
                for (p, q) in move2:
                    i, j = x2+p, y2+q
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        yet.append((i, j))

    print(ans[goal_h][goal_w])

if __name__ == "__main__":
    main()


Measured memory_bytes: 23668
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    var input = args.split(' ');
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
    var count = 0;

    for(var i=A; i<=B; i++){
        var tmp = i.toString();
        (tmp[0]===tmp[4] && tmp[1]===tmp[3]) ? count++ : '';
    }

    console.log(count);
}

Measured memory_bytes: 10680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int l,r,d;cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            ans++;
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MAX_N 5000
#define MAX_K 5000
using namespace std;
int dpl[MAX_N+1][MAX_K];
int dpr[MAX_N+1][MAX_K];
int a[MAX_N];
int N,K;
int main(void){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    dpl[0][0]=1;
    dpr[N][0]=1;
    for(int y=1;y<K;y++){
        dpl[0][y]=0;
        dpr[N][y]=0;
    }
    for(int x=0;x<N;x++){
        for(int y=0;y<K;y++){
            if (dpl[x][y]==1){
                dpl[x+1][y]=1;
                if (y+a[x]<K){
                    dpl[x+1][y+a[x]]=1;
                }
            }
            if (dpr[N-x][y]==1){
                dpr[N-1-x][y]=1;
                if(y+a[N-1-x]<K){
                    dpr[N-1-x][y+a[N-1-x]]=1;
                }
            }
        }
    }
    int ans=0;
    for(int x=0;x<N;x++){
        int Sx[MAX_K+1];
        for(int i=0;i<K;i++){
            Sx[i+1]=Sx[i]+dpl[x][i];
        }
        int flag=0;
        for(int y=0;y<K;y++){
            if(dpr[x+1][y]==1){
                int high=K-y;
                int low=K-y-a[x];
                if (low<0){
                    low=0;
                }
                if (Sx[high]-Sx[low]>0){
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i <= S.size(); i++) {
    for (int j = 0; j <= S.size() - i; j++) {
      string str = S.substr(i,S.size() - i - j);
      bool Yes = true;
      for (int k = 0; k < str.size(); k++) {
        if (str[k] != 'A' && str[k] != 'C' && str[k] != 'G' && str[k] != 'T') {
          Yes = false;
        }
      }
      if (Yes) {
        ans = max(ans,(int)(str.length()));
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;


int main() {
    int N;
    cin>>N;
    map<string,int> mp;
    string s;
    ll count=0;
    REP(i,N){
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    sort(s.begin(),s.end());

    for(auto&p:mp){
        int s=p.second;
        count+=(ll)s*(s-1)/2;
    }
    cout<<count<<endl;
    return 0;
}





Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using un = uint64_t;

int main(){
  un N;
  cin >> N;
  vector<un>vec(N);
  for (un i=0; i<N; i++) cin >> vec.at(i);
  un yen = 1000;
  un cnt = 0;
  for (un i=0; i<N-1; i++){
    if(vec.at(i) < vec.at(i+1)){
      cnt += yen / vec.at(i);
      yen = yen % vec.at(i);
    }else if(vec.at(i) > vec.at(i+1)){
      yen += cnt * vec.at(i);
      cnt = 0;
    }
  }
  yen += cnt * vec.at(N-1);
  cout << yen << endl;
}

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

using namespace std;

int main(){
    long long int takahasi,nakahasi,hikuhasi,K;
    cin>>takahasi>>nakahasi>>hikuhasi>>K;

    if(K%2==0){
        K=2;
    }else if(K%2==1){
        K=1;
    }

    if(takahasi==nakahasi==hikuhasi){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=K;i++){
    long long int a=takahasi;
    long long int b=nakahasi;

    takahasi=nakahasi+hikuhasi;
    nakahasi=a+hikuhasi;
    hikuhasi=a+b;

   //cout<<takahasi<<" "<<nakahasi<<" "<<hikuhasi<<endl;
    
    if(takahasi-nakahasi>=1000000000000000000){
        cout<<"Unfair"<<endl;
    }
    }

    cout<<takahasi-nakahasi<<endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>

using namespace std;

int field[200][200];
bool visited[200][200];

int T, N, SX, SY;

int ty[] = {1, 1, 0, -1, -1, 0};
int tx[] = {1, 0, -1, -1, 0, 1};

void init() {
  fill(&field[0][0], &field[199][200], 0);
  fill(&visited[0][0], &visited[199][200], false);
}
struct P {
  int x, y, c;
  P(int x, int y, int c) : x(x), y(y), c(c) {}
};
int _solve(int x, int y, int depth) {
  queue<P> Q;
  
  Q.push(P(x, y, 0));

  while (!Q.empty()) {
    P cur = Q.front();
    Q.pop();
    int cx = cur.x;
    int cy = cur.y;
    int d = cur.c;
    if (visited[cy][cx] || field[cy][cx] == 1 || d > T) {
      continue;
    }
    visited[cy][cx] = true;
    for (int i = 0; i < 6; i++) {
      int nx = cx + tx[i];
      int ny = cy + ty[i];
      Q.push(P(nx, ny, d + 1));
    }
  }
}

void solve() {
  int res = _solve(SX + 100, SY + 100, 0);
  int cnt = 0;
  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 200; j++) {
      if (visited[i][j]) {
        cnt++;
      }
    }
  }
  printf("%d\n", cnt);
}

void print_field() {

}


int main() {
  while (true) {
    scanf("%d %d ", &T, &N);
    if (T == 0 && N == 0) {
      return 0;
    }
    init();
    
    for (int i = 0; i < N; i++) {
      int x, y;
      scanf("%d %d ", &x, &y);
      field[y + 100][x + 100] = 1;
    }
    scanf("%d %d ", &SX, &SY);
    solve();
  }
}

Measured memory_bytes: 1132
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=998244353,N=100000;
const double pi=acos(-1.0);
typedef long long ll;
int n,k,c[4010][4010],bin[4010];

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

void init()
{
	k=read();n=read();
	int i,j;
	c[0][0]=1;
	for (i=1;i<=4000;i++)
	{
		c[i][0]=1;
		for (j=1;j<=i;j++)
			c[i][j]=((ll)c[i-1][j]+c[i-1][j-1])%maxd;
	}
	bin[0]=1;
	for (i=1;i<=4000;i++) bin[i]=(bin[i-1]*2)%maxd;
	//for (i=1;i<=6;i++) cout << bin[i] << " ";cout << endl;
}

ll calc(int x,int y,int z)
{	
	if (y<0) return 0;
	//cout << x << " " << y << " " << z << endl; 
	int i;ll ans=0;
	for (i=0;i<=x&&i<=z;i++)
	{
		if (((i+y-1)>=0) && ((i+y-1)<=(z+y-1)))
		{
			//cout << i << " " << x << " " << y << " " << z << endl;
			ans=(ans+((1ll*c[x][i]*bin[i])%maxd*c[z+y-1][i+y-1])%maxd)%maxd;
		}
	}
	return ans;
}

void work()
{
	int i,j;
	for (i=2;i<=k*2;i++)
	{
		ll ans=0;int cnt=0;
		for (j=1;j<=k;j++)
		{
			int tmp=i-j;
			if ((tmp<=k) && (tmp>=1)) cnt++;
		}
		//cout << i << " " << cnt << endl;
		if (i&1)
			ans=calc(cnt/2,k-cnt,n);
		else 
			ans=(calc((cnt-1)/2,k-cnt,n)+calc((cnt-1)/2,k-cnt,n-1))%maxd;
		printf("%lld\n",ans);
	}
}		

int main()
{
	init();
	work();
	return 0;
}


Measured memory_bytes: 61568