akhauriyash/Code-Regression huggingface dataset:
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		Double r = sc.nextDouble();

		BigDecimal area = new BigDecimal(r * r * Math.PI);
		BigDecimal cir =  new BigDecimal(r * 2 * Math.PI);


		System.out.println(area + " " + cir);

	}

}



Measured memory_bytes: 28304
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 200003
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def dft(f,n):
    if n == 1:
        return f
    f0 = dft(f[0::2],n//2)
    f1 = dft(f[1::2],n//2)
    zeta = complex(math.cos(2*math.pi/n),math.sin(2*math.pi/n))
    pow_zeta = 1
    for i in range(n):
        f[i] = f0[i%(n//2)] + pow_zeta*f1[i%(n//2)]
        pow_zeta *= zeta
    return f

def reverse_dft(f,n):
    if n == 1:
        return f
    f0 = reverse_dft(f[0::2],n//2)
    f1 = reverse_dft(f[1::2],n//2)
    zeta = complex(math.cos(2*math.pi/n),-math.sin(2*math.pi/n))
    pow_zeta = 1
    for i in range(n):
        f[i] = f0[i%(n//2)] + pow_zeta*f1[i%(n//2)]
        pow_zeta *= zeta
    return f

def multiply(g,h):
    n = 2**len(format((len(g)+len(h)+1),'b'))
    g += [0]*(n-len(g))
    h += [0]*(n-len(h))
    gg = dft(g,n)
    hh = dft(h,n)
    ff = [gi*hi for gi,hi in zip(gg,hh)]
    return [int(ffi.real/n+0.1) for ffi in reverse_dft(ff,n)]

def main():
    n = int(ipt())
    g = 2
    order = [1]
    for i in range(mod-2):
        order.append(order[-1]*g%mod)
    where = [0]*mod
    for i,oi in enumerate(order):
        where[oi] = i

    nms = [0]*(mod-1)
    for i in map(int,ipt().split()):
        if i == 0:
            continue
        nms[where[i]] += 1

    ans = 0
    for i,ni in enumerate(nms):
        ans -= ni*order[(i*2)%(mod-1)]

    nn = multiply(nms*1,nms*1)

    for i in range(2*(mod-1)-1):
        ans += nn[i]*order[i%(mod-1)]

    print(ans//2)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 299000
import itertools
import numpy as np
import math

n = int(input())
xy = []
for i in range(n):
    x, y = map(int, input().split())
    xy.append([x, y])

lis = [x for x in range(n)]

p_list = itertools.permutations(lis)

s = 0

for one_case in p_list:
    prev = 0
    for i in range(n):
        if i == 0:
            prev = one_case[0]
        else:
            s += np.sqrt((xy[one_case[i]][0] - xy[prev][0])**2 + (xy[one_case[i]][1] - xy[prev][1])**2)
            prev = one_case[i]
print(s/math.factorial(n))

Measured memory_bytes: 26984
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";

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

  int n, m;
  cin >> n >> m;
  if(n == m){
    cout << YES << endl;
  }else{
    cout << NO << endl;
  }




}


Measured memory_bytes: 256
#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;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < 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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n,m;
int a[100000];
int dp[100001];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for(int i=0;i<m;i++) cin>>a[i];
    dp[0]=1;
    dp[1]=1;
    int j=0;
    if(a[0]==1){
        dp[1]=0;
        j++;
    }
    for(int i=2;i<=n;i++){
        if(j<m&&a[j]==i){
            dp[i]=0;
            j++;
        }
        else{
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=1000000007;
        }
    }
    cout <<dp[n]<< "\n";
}

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A1, A2, A3;
    vector<ll> A(3);

    cin >> A1 >> A2 >> A3;

    A[0] = abs(A1 - A2);
    A[1] = abs(A2 - A3);
    A[2] = abs(A3 - A1);

    sort(all(A));

    cout << A[0] + A[1] << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n; cin >> n;
    double jpy, btc;
    jpy = btc = 0.0;
    for(int i = 0; i < n; i++){
        double val;
        string s;
        cin >> val >> s;
        if(s == "JPY") jpy += val;
        else btc += val; 
    }
    cout << setprecision(5) << fixed << jpy + btc * 380000 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

//公約数
int gcd(int a, int b){
  if(a == 0 || b == 0)return max(a, b);
  if(a == b)return a;
  if(a > b)a = a%b;
	else b = b%a;
  return gcd(a, b);
}
//公倍数
int lcm(int a, int b){
  if(a == 0)return 0;
  return a/gcd(a, b)*b;
}

signed main(){
  int a, b;
  scanf("%lld%lld", &a, &b);
  string s, t;
  cin >> s >> t;
  int m = lcm(a, b);
  int ans = 1, p = 0;
  rep(i,inf){
    int x = i*(m/b), y = i*(m/a);
    if(a <= x)break;
    if(s[x] != t[y])ans = 0;
  }
  printf("%lld\n", ans ? m : -1);
	return 0;
}










Measured memory_bytes: 512
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL h;
map<LL, LL> memo;

LL calc(LL x){
    if(memo[x] != 0)return memo[x];
    if(x == 1)return memo[x] = 1;

    return memo[x] = 1LL + calc(x/2) + calc(x/2);
}

int main(){
    cin >> h;
    cout << calc(h) << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
ll a[20][20];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll n,m,x;
    cin>>n>>m>>x;
    vector <ll> c(n);
    ll ans=INFLL;
    for (int i=0;i<n;i++)
    {
        cin>>c[i];
        for (int j=0;j<m;j++)
            cin>>a[i][j];
    }
    for (int mask=0;mask<(1<<n);mask++)
    {
        vector <int> b(m);
        ll sum=0;
        for (int i=0;i<n;i++)
        {
            if ((mask>>i)&1)
            {
                for (int j=0;j<m;j++)
                    b[j]+=a[i][j];
                sum+=c[i];
            }
        }
        bool ok=true;
        for (int i=0;i<m;i++)
        {
            if (b[i]<x)
                ok=false;
        }
        if (ok)
            ans=min(ans,sum);
    }

    ans==INFLL ? cout<<-1 : cout<<ans;





}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x*t << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;

ll dp[200001];

int main()
{
  int n;
  scanf("%d", &n);
  
  for(int i = 1; i <= n; i++)
  {
    dp[i] = dp[i-1];
    
    int cur = i;
    int last = cur % 10;
    int first = last;
    int digit = 1;
    cur /= 10;
    
    while(cur > 0)
    {
      first = cur % 10;
      cur /= 10;
      digit++;
    }
    
    if(last == 0)
      continue;
    
    if (last == first)
    {
      if (i == last)
        dp[i] += 1;
      else if(i > last)
        dp[i] += 2;
    }
    
    int res = last * 10 + first;
    int rdigit = 2;
    
    while(res <= i)
    {
      if(last == first)
      {
        if (rdigit == digit)
          dp[i] += 2 * ((i-res)/10) + 1;
        else
          dp[i] += 2 * (int)pow(10, rdigit-2);
      }
      else
        dp[i] += 2 * (int)pow(10, rdigit-2);
      
      res = (res-first)*10 + first;
      rdigit++;
    }
  }
  
  printf("%lld\n", dp[n]);
  
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

long long int cnt;
vector<int> G;

void insertionSort(vector<int> &a,int n,int g){
	for (int i=g;i<n;i++){
    	int v=a.at(i);//gの間隔後から
    	int j=i-g;//最初はゼロから
      	while(j>=0 && a.at(j)>v){
        	a.at(j+g)=a.at(j);
          	j-=g;
          	cnt++;
        }
      a.at(j+g)=v;
    }
}

void shellSort(vector<int> &a,int n){
	//数列Gを生成
  	for(int h=1;;){
    	if(h>n)break;
      	G.push_back(h);
      	h=3*h+1;
    }
	for (int i=G.size()-1;i>=0;i--){
		insertionSort(a,n,G.at(i));
	}
  	
}

int main(){
	int n;cin>>n;
  	vector<int> a(n);
  
  	//数字を読み込み	
  	for(int i=0;i<n;i++){
    	scanf("%d",&a.at(i));
      	cnt=0;
    }
  	
  	shellSort(a,n);
  	cout<<G.size()<<endl;
  	for (int i=G.size()-1;i>=0;i--){
    	printf("%d",G.at(i));
        if(i) printf(" ");
    }
   	printf("\n");
   	printf("%d\n",cnt);
  	for (int i=0;i<n;i++) printf("%d\n",a.at(i));
  }


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

class UnionFind:
    def __init__(self, n):
        # 全て根 (par[x] = x) として初期化
        self.par = list(range(n))
        self.siz = [1] * n
    
    def root(self, x):
        """データxが属する木の根を再帰で得る
        """
        if self.par[x] == x: return x  # 根ならそのまま返す
        self.par[x] = self.root(self.par[x])  # 経由したノード全ての親を上書き
        return self.par[x]

    def size(self, x):
        """データxが属する木のサイズを返す
        """
        return self.siz[self.root(x)]
    
    def unite(self, x, y):
        """xとyの木を併合する
        """
        rx, ry = self.root(x), self.root(y)
        if rx != ry:  # xとyの根が違う (=違う木である) 場合
            if self.siz[rx] < self.siz[ry]: rx, ry = ry, rx  # xの木の方が大きくなるようにする
            self.siz[rx] += self.siz[ry]
            self.par[ry] = rx  # yの根をxの根につける

    def same(self, x, y):
        """2つのデータx, yが属する木が同じならTrueを返す
        """
        rx, ry = self.root(x), self.root(y)
        return rx == ry

n, m, k = map(int, input().split())
uf = UnionFind(n)
n_friends = [0] * n
n_blocks = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    uf.unite(a, b)
    n_friends[a] += 1
    n_friends[b] += 1

for i in range(k):
    c, d = map(int, input().split())
    c, d = c-1, d-1
    if uf.same(c, d):
        n_blocks[c] += 1
        n_blocks[d] += 1

ans = []
for i in range(n):
    ans.append(uf.size(i) - n_friends[i] - n_blocks[i] - 1)
print(*ans)



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

int main() {
    string S;
    cin >> S;
    
    lint ans = 0;
    int cnt = 0;
    
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == 'W'){
            ans += i - cnt;
            ++cnt;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MAXN = 107;
const int MX = 100 * 1000 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;

int f[MAXN][MX];
int sf[MAXN][MX];
int a[MAXN];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    f[0][0] = 1;
    for (int i = 0; i < MX; i++) {
        sf[0][i] = 1;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < MX; j++) {
            int l = j - a[i];
            f[i][j] = sf[i - 1][j];
            if (l > 0) {
                f[i][j] = (f[i][j] + MOD - sf[i - 1][l - 1]) % MOD;
            }
        }
        sf[i][0] = f[i][0];
        for (int j = 1; j < MX; j++) {
            sf[i][j] = (sf[i][j - 1] + f[i][j]) % MOD;
        }
    }

    cout << f[n][k] << "\n";
    return 0;
}



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

using namespace std;

typedef long long ll;

ll pow_mod(ll x,int k,ll MOD) {
  ll ans=1;
  while (k) {
  	if (k&1) ans=ans*x%MOD;
  	x=x*x%MOD;
  	k>>=1;
  }
  return ans;
}

const int prime[10]={998244353,989390509,807943519,934784771,814294163,847763881,988501229,831312439,887199301,993514421};
const ll H[10]={19260817,760277961,602494845,909561729,536778743,682353612,738823132,631427472,848965391,984035289};

int powd[10][1000005],invd[10][1000005];

void pre(int n) {
  for(int i=0;i<10;i++) {
    ll inv=pow_mod(H[i],prime[i]-2,prime[i]);
    assert(inv*H[i]%prime[i]==1);
    powd[i][0]=1;
    for(int j=1;j<=n;j++) powd[i][j]=(ll)powd[i][j-1]*H[i]%prime[i];
    invd[i][0]=1;
    for(int j=1;j<=n;j++) invd[i][j]=(ll)invd[i][j-1]*inv%prime[i];
  }
}

struct Data {
  int num[10];
  Data() {memset(num,0,sizeof(num));}
  Data operator + (Data b) {
  	Data c;
  	for(int i=0;i<10;i++) c.num[i]=(num[i]+b.num[i])%prime[i];
  	return c;
  }
  void add(int x) {
  	for(int i=0;i<10;i++) num[i]=(num[i]+powd[i][x])%prime[i];
  }
  void dec(int x) {
  	for(int i=0;i<10;i++) num[i]=(num[i]-powd[i][x]+prime[i])%prime[i];
  }
  void rshift(int x) {
  	for(int i=0;i<10;i++) num[i]=(ll)num[i]*powd[i][x]%prime[i];
  }
  void lshift(int x) {
  	for(int i=0;i<10;i++) num[i]=(ll)num[i]*invd[i][x]%prime[i];
  }
  bool operator < (const Data & b) const {
  	for(int i=0;i<10;i++)
  	  if (num[i]!=b.num[i]) return num[i]<b.num[i];
  	return 0;
  }
};

map <Data,int> mp;
Data p[250005];

char str[250005];

int main() {
  int n;
  scanf("%d%s",&n,str+1);
  pre(4*n);
  int d=0;
  for(int i=1;i<=n;i++) {
  	p[i]=p[i-1];
    if (str[i]=='+') p[i].add(2*n+d);
    else if (str[i]=='-') p[i].dec(2*n+d);
    else if (str[i]=='>') d++;
    else d--;
    mp[p[i]]++;
  }
  ll ans=0;
  d=0;
  for(int i=1;i<=n;i++) {
  	Data t=p[n];
  	if (d>=0) t.rshift(d); else t.lshift(-d);
	t=t+p[i-1];
	if (mp.count(t)) ans+=mp[t];
	if (str[i]=='>') d++;
	else if (str[i]=='<') d--;
	mp[p[i]]--;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 111872
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main() {
	int H,N;
    cin >> H >> N;
    vector<int> A(N);
    for(int& e:A)cin >> e;
	cout <<( (H <= accumulate(A.begin(),A.end(),0)) ? "Yes":"No" )<< endl;
	return 0;
}


Measured memory_bytes: 640
# get input parameter
h, w, a, b = map(int, input().split())

# zero, one string
zero_str = '0'
one_str = '1'

# loop for b rows
for index in range(b):
    print(zero_str * a + one_str * (w - a))

# loop for (h-b) rows
for index in range(h-b):
    print(one_str * a + zero_str * (w - a))


Measured memory_bytes: 3956
n = int(input())
c = list(input())


sum_r, sum_w = [0], [0]
s1, s2 = 0, 0
for v in c:
    if v == 'R':
        s1 += 1
    else:
        s2 += 1
    sum_r.append(s1)
    sum_w.append(s2)

res = float('inf')
for i in range(n+1):
    res = min(res, max(sum_w[i], s1 - sum_r[i]))

print(res)

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



int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> r, g, rg;
	long count = 0;
	for (int i = 0;i < a;i++) {
		int d;
		cin >> d;
		r.push_back(d);
	}
	for (int i = 0;i < b;i++) {
		int d;
		cin >> d;
		g.push_back(d);
	}
	for (int i = 0;i < c;i++) {
		int d;
		cin >> d;
		rg.push_back(d);
	}
	sort(r.rbegin(), r.rend());
	sort(g.rbegin(), g.rend());
	sort(rg.rbegin(), rg.rend());
	vector<int> t;
	for (int i = 0;i < x;i++) {
		count = count + r[i];
		t.push_back(r[i]);
	}


	for (int i = 0;i < y;i++) {
		count = count + g[i];

		t.push_back(g[i]);
	}
	sort(t.begin(), t.end());
	long ans = count;
	for (int i = 0;i < min(x + y, c);i++) {
		count = count + rg[i] - t[i];
		ans = max(ans, count);
	}
	cout << ans;
}

Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
VI A;
vector<VI > x,y;

int main()
{

	cin >> N;
	A.resize(N);
	x.resize(N);
	y.resize(N);
	REP(i,N){
		cin >> A[i];
		x[i].resize(A[i]);
		y[i].resize(A[i]);
		REP(j,A[i]){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}


	int ansmax = 0;
	REP(i,pow(2,N)){
		int ii = i;
		vector<bool> ans;
		ans.resize(N);
		int iii = 0;
		int a = 0;
		while(ii>0){
			if(ii%2==0){
				ans[iii] = false;
			} else {
				ans[iii] = true;
				a++;
			}
			ii/=2;
			iii++;
		}
		bool OK = true;
		REP(j,N){
			if(ans[j]){
				REP(k,A[j]){
					if(ans[x[j][k]]!=y[j][k]){
						OK = false;
						break;
					}
				}
			}
		}
		if(OK==true){
			ansmax = max(a,ansmax);
		}
	}
	cout << ansmax;
}





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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

void print(vint as) {
    rep(i, as.size()) cout << as[i] << " ";
    cout << endl;
}

vint solve(vint cur) {
    rep(i, cur.size()) {
        if (cur[i] > i + 1) return vint();
    }
    if (cur.size() == 1 && cur[0] == 1) {
        vint ans;
        ans.pb(1);
        return ans;
    }
    rep(i, cur.size()) {
        if (cur[i] != i + 1) {
            continue;
        }
        vint ccur;
        rep(j, cur.size()) {
            if (j != i) {
                ccur.pb(cur[j]);
            }
        }
        vint ret = solve(ccur);
        if (ret.size() == ccur.size()) {
            ret.pb(i + 1);
            return ret;
        }
    }
    return vint();
}

signed main(void){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint as = vint(n);
    rep(i, n) cin >> as[i];
    vint ans = solve(as);
    if (ans.size() != as.size()) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 384
import numpy as np
A = []
marubatsu = np.zeros((3,3),dtype=int)

for _ in range(3):
    a = list(map(int, input().split()))
    A.append(a)
    
n = int(input())
lott = []
for _ in range(n):
    lott.append(int(input()))

for i in lott:
    for j in range(3):
        for k in range(3):
            if A[j][k] == i:
                marubatsu[j,k] = 1
                break
            else:
                continue
            break
        
def bingo_tate_yoko(marubatsu):
    for i in range(3):
        if np.sum(marubatsu, axis=0)[i] == 3 or np.sum(marubatsu, axis=1)[i] == 3:
            return(1)
            break
        elif i == 2:
            return(0)

def bingo_naname(marubatsu):
    if marubatsu[0,0]+marubatsu[1,1]+marubatsu[2,2] == 3 or marubatsu[0,2]+marubatsu[1,1]+marubatsu[2,0] == 3:
        return(1)
    else:
        return(0)

if bingo_tate_yoko(marubatsu) == 1:
    print('Yes')
elif bingo_naname(marubatsu) == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12260
#include<stdio.h>

int main(){

	int n,x=0;
	scanf("%d",&n);
	
	if(n>=1 && n<=81){
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
			if(i*j == n && i>=j){
				printf("Yes");
				x++;
				break;
			}
		}
		if(x > 0){
			break;
		}
		}
		if(x == 0){
			printf("No");
		}
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 1704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Secret Investigation
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());

		boolean[] A = new boolean[N];
		boolean[] B = new boolean[N];
		boolean[] C = new boolean[N];

		boolean[][] sets = {A, B, C};

		for (boolean[] set : sets) {

			StringTokenizer st = new StringTokenizer(br.readLine());
			st.nextToken();

			while (st.hasMoreTokens()) {
				int i = parseInt(st.nextToken());
				set[i - 1] = true;
			}
		}

		int count = 0;

		for (int i = 0; i < N; i++) {
			if ((!A[i] && C[i]) || (B[i] && C[i])) count++;
		}

		System.out.println(count);
	}
}

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

int main(){
	string s;
	int u = 0,d = 0;
	int UH = 0,DH = 0;
	cin >> s;
	d = s.size() - 1;
	while (UH == 0) {
		if (s.substr(u,1) == "A" ) {
			UH = 1;
		}

		else u++;

	}

	while (DH == 0) {
		if (s.substr(d,1) == "Z") {
			DH = 1;
		}

		else d--;

	}

	cout << d - u + 1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;


const ll MOD = 1e9+7;

ll dp[100009][2];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);

  string s;
  cin >> s;

  ll  mul = 1;
  ll ans = 0;

  ////  1 1 0   110
  //    1 0 1 -->0
  //    0 1 1 --> 0
  //    0 0 0 --> 0
  // 0 <=
  // 1 < 
  dp[0][0] = 3;
  dp[1][0] = 1;
  rep(i, 1, s.size()-1) {
    mul = (mul *3) % MOD;
    if (s[i] == '1') {
      dp[0][i] = (dp[0][i-1] * 3) % MOD;
      dp[1][i] = (dp[1][i-1] * 2) % MOD + dp[0][i-1];
      dp[1][i] %= MOD;
    } else {
      dp[0][i] = (dp[0][i-1] + dp[1][i-1]* 2) % MOD;
      dp[1][i] = (dp[1][i-1] * 3) % MOD;
    }
  }

  cout << dp[0][s.size()-1]<< endl;

}


Measured memory_bytes: 1232
#n=int(input())
#li=input().split()
#li=list(map(int,input().split()))
n=input()
check=0
for i in range(len(n)-1):
    a=n[i:i+2]
    if a[0]==a[1]:
        check=1
        ans=i
        break

if check==0:
    for j in range(len(n)-2):
        b=n[j:j+3]
        if b[0]==b[1] or b[0]==b[2] or b[1]==b[2]:
            check=2
            ans=j
            break

if check==1:
    print(ans+1,ans+2)
if check==2:
    print(ans+1,ans+3)
if check==0:
    print(-1,-1)


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main() {
	int a, b;
	unsigned long f;
	f = 100000;
	cin >> a;
	for (int i = 0; i < a; i++){
		f += f / 20;
		if (f % 1000 != 0) {
			b = f % 1000;
			f += 1000 - b;
		}
	}
	cout << f << endl;
	char k;
	cin >> k;
}

Measured memory_bytes: 3104
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
unsigned int a,b,d,r;
double f;
 cin >> a >> b;
d=a/b;
r=a%b;
 f=((double)a)/b;
 printf("%d %d %.6f\n",d,r,f);
return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <stdio.h>
#include <map>
#include <algorithm>
using namespace std;
const int maxn=500005;
struct node
{
    int l,r,sum;
} tree[maxn*4];
struct ques
{
    int l,r,index;
}ask[maxn];
int a[maxn];
int ans[maxn];
void build(int i,int left,int right)
{
    tree[i].l=left,tree[i].r=right;
    tree[i].sum=0;
    if(left==right)
        return;
    int mid=left+right>>1;
    build(i<<1,left,mid);
    build(i<<1|1,mid+1,right);
}
map<int,int> has;
void update(int i,int pos ,int w)
{
    if(tree[i].l==pos&&tree[i].r==pos)
    {
        tree[i].sum+=w;
        return ;
    }
    int mid=(tree[i].l+tree[i].r)>>1;
    if(pos<=mid)
        update(i<<1,pos ,w);
    else
        update(i<<1|1,pos ,w);
    tree[i].sum=tree[i<<1].sum+tree[i<<1|1].sum;
}
int query(int i,int left,int right)
{
    if(tree[i].l==left&&tree[i].r==right)
    {
        return tree[i].sum;
    }
    int mid=(tree[i].l+tree[i].r)>>1;
    if(right<=mid)
        return query(i<<1,left,right);
    else if(left>mid)
        return query(i<<1|1,left,right);
    else
        return query(i<<1,left,mid)+query(i<<1|1,mid+1,right);
}
bool cmp(ques a,ques b)
{
    return a.r<b.r;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    build(1,1,n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
    {
        ask[i].index=i;
        scanf("%d%d",&ask[i].l,&ask[i].r);
    }
    sort(ask+1,ask+1+m,cmp);
    int cur=1;
    for(int i=1;i<=m;i++)
    {
        for(int j=cur;j<=ask[i].r;j++)
        {
            if(has.find(a[j])!=has.end())
            {
                int p=has[a[j]];
                update(1,p ,-1);
            }
            update(1,j, 1);
            has[a[j]]=j;
        }
        cur=ask[i].r+1;
        ans[ask[i].index]=query(1,ask[i].l,ask[i].r);
    }
    for(int i=1;i<=m;i++)
        printf("%d\n",ans[i]);
}  

Measured memory_bytes: 49264
import sys
import collections
import itertools
import math
import re
from collections import deque

MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

D = int(input())

s = "Christmas"
ret = s
while D != 25:
    ret += " Eve"
    D += 1

print(ret)



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

int main(){
  
  int n,T;
  cin >>n>>T;
  int c[n],t[n];
  for(int i=0; i<n; i++) cin >> c[i] >> t[i];
  
  int ans=2000;
  for(int i=0; i<n; i++){
  	if(t[i]<=T) ans=min(ans,c[i]);
  }
  
  if(ans==2000) cout << "TLE"<< endl;
  else cout << ans << endl;
}

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

using i64 = long long;

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> H(N);
  for (auto&& x : H) cin >> x;

  sort(H.begin(), H.end());
  i64 res = 0;
  for (int i = 0; i < N - K; i++) {
    res += H[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 4828
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;

int main()
{
  long N; cin >> N;
  long a[100005] = {};
  for (int i = 1; i <= N; i++)
  {
    cin >> a[i];
  }
  
  long S[100005]; // 第i項までの和
  S[0] = 0;
  
  // S[1]をプラスとしてスタート
  long ans_positive = 0;
  
  for (int i = 1; i <= N; i += 2)
  {
    // S[i]はプラス
    if (S[i - 1] + a[i] > 0)
    {
      S[i] = S[i - 1] + a[i];
    }
    else // S[i - 1] + a[i] <= 0
    {
      S[i] = 1;
      ans_positive += abs(1 - S[i - 1] - a[i]);
    }
    
    if (i == N) break;
    
    // S[i + 1]はマイナス
    if (S[i] + a[i + 1] < 0)
    {
      S[i + 1] = S[i] + a[i + 1];
    }
    else // S[i] + a[i + 1] >= 0
    {
      S[i + 1] = -1;
      ans_positive += abs(-1 - S[i] - a[i + 1]);
    }
  }
  
  S[0] = 0;
  
  // S[1]をマイナスとしてスタート
  long ans_negative = 0;
  
  for (int i = 1; i <= N; i += 2)
  {
    
    // S[i]はマイナス
    if (S[i - 1] + a[i] < 0)
    {
      S[i] = S[i - 1] + a[i];
    }
    else // S[i - 1] + a[i] >= 0
    {
      S[i] = -1;
      ans_negative += abs(-1 - S[i - 1] - a[i]);
    }
    
    if (i == N) break;
    
    // S[i + 1]はプラス
    if (S[i] + a[i + 1] > 0)
    {
      S[i + 1] = S[i] + a[i + 1];
    }
    else // S[i] + a[i + 1] <= 0
    {
      S[i + 1] = 1;
      ans_negative += abs(1 - S[i] - a[i + 1]);
    }
  }
  
  cout << min(ans_positive, ans_negative) << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int h=Integer.parseInt(in.next()),w=Integer.parseInt(in.next());
			if(h==0)break;
			double X=crosspow(h,w);

			int Mmh=101,Mmw=101;
			double mX=crosspow(Mmh,Mmw);
			for(int i=1;i<=150;i++) {
				for(int j=i+1;j<=150;j++) {
					double cx=crosspow(i,j);

					if(cx>X || (cx>=X && i>h)) {
						if(cx<mX || (cx<=mX && i<Mmh)) {
							Mmh=i; Mmw=j;
							mX=crosspow(Mmh,Mmw);
						}
					}
				}
			}

			System.out.println((int)Mmh+" "+(int)Mmw);
		}
	}

	static double crosspow(int a,int b) {
		return Math.pow(a, 2)+Math.pow(b, 2);
	}
}


Measured memory_bytes: 27676
#include <bits/stdc++.h>
using namespace std;
int n, z;
char s[320][320];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}
	for (int i = 0; i < n; i++) {
		int b = 1;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (s[(j + i) % n][k] != s[(k + i) % n][j]) {
					b = 0;
				}
			}
		}
		z += b;
	}
	printf("%d\n", z * n);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>

int n, A[20];

int solve(int i, int m) {
  if (!m) return 1;
  if (!(n - i)) return 0;
  return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main() {
  int q, m;
  std::scanf("%d", &n);
  for (int i = 0; i < n; ++i) std::scanf("%d", &A[i]);
  std::scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    std::scanf("%d", &m);
    std::printf("%s\n", solve(0, m) ? "yes" : "no");
  }
  return 0;
}



Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1e9+7;
const int mex=1e6+1;
int main()
{
    fast
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int dp[n+1][m+1];
    fill(dp,0);
    rp(i,1,n+1)
    {
        rp(j,1,m+1)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string a;
    int i=n,j=m;
    while(i>0 && j>0)
    {   
        if(s[i-1]==t[j-1])
        {
            a.pb(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j-1]<dp[i-1][j])
        {
            i--;
        }
        else j--;
    }
    reverse(all(a));
    cout<<a;
    return 0;
}

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

int main(void){
	cin >> S >> T;
    rep(i,3){
      if(S[i] == T[i]) ans++;
    }
  cout << ans << endl;
}


Measured memory_bytes: 256
=begin
戦略：連続する<<< >>>ごとに区切る。また、区切り> <は必ず0になる
=end

s = gets.chomp
n = s.size

sum = 0
n = 0
count = 0
state = true

s.each_char do |c|
  if (c == '<') === state
    count += 1
  else
    if state
      n = count
    else
      sum += n * (n + 1) / 2
      sum += count * (count + 1) / 2
      sum -= [n, count].min
    end
    state = !state
    count = 1
  end
end

if state
  sum += count * (count + 1) / 2
else
  sum += n * (n + 1) / 2
  sum += count * (count + 1) / 2
  sum -= [n, count].min
end

puts sum

Measured memory_bytes: 4868
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

int main(void)
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  char c[2];
  
  for(int i=0;i<S.size();i++)
  {
    if( (S[i]+N) > 90) S[i] = S[i] -26;
  	snprintf(c,2,"%c", (S[i]+N) );
  	cout << c[0];
  }  
  return 0;
} 

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

typedef long long ll;
const int N=1010;
int n,k;
ll a[N],ans;
ll pre[N];
vector<ll>v,v1;

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",a+i);
	for(int i=1;i<=n;i++){
		ans=0;
		for(int j=i;j<=n;j++){
			ans+=a[j];
			v.push_back(ans);
		}
	}
//	for(int i=0;i<v.size();i++) printf("%d ",v[i]);
//	puts("");
	ans=0;
	for(int i=60;i>=0;i--){
		for(int j=0;j<v.size();j++)
			if(v[j]>>i&1) v1.push_back(v[j]);
		if(v1.size()>=k){
			v=v1;
			ans+=1LL<<i;
		}
		v1.clear();
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

const int N = int(1e7) + 1;
int cnt[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    for (int i = 1; i < N; ++i)
        for (int j = i; j < N; j += i)
            ++cnt[j];
    long long ans = 0LL;
    int n;
    cin >> n;
    for (int k = 1; k <= n; ++k) ans += 1LL * k * cnt[k];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 42708
n = int(raw_input())
l = map(int, raw_input().split())
c = [0 for _ in xrange(10**5+1)]
for i in l:
    c[i] += 1
ans = 0
for i in xrange(1,10**5):
    ans = max(ans, c[i-1]+c[i]+c[i+1])
print ans


Measured memory_bytes: 11304
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using T = ll;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


ll dp[1333][1333];
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};
bool seen[1333][1333];
int h, w;
bool s2[1333][1333];
vector<string> fld(1333);
void dfs(int y, int x, queue<P> &q){
    s2[y][x] = true;
    seen[y][x] = true;
    rep(i, 4){
        int ny = y + dy[i], nx = x + dx[i];
        if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
        if(s2[ny][nx])continue;
        if(fld[ny][nx] == '#')continue;
        dp[ny][nx] = dp[y][x];
        q.emplace(ny, nx);
        dfs(ny, nx, q);
    }
}

int main(){
   int sx, sy, gx, gy;
   cin >> h >> w >> sy >> sx >> gy >> gx;
   sy--;sx--;gy--;gx--;
   rep(i, h)cin >> fld[i];

   queue<P> que;
   que.emplace(sy, sx);
   rep(i, h)rep(j, w)dp[i][j] = -1;
   dp[sy][sx] = 0;

   while(!que.empty()){
       int yy = que.front().first, xx = que.front().second;
       seen[yy][xx] = true;
       que.pop();
       queue<P> q;
       q.emplace(yy, xx);
       dfs(yy, xx, q);
       while(!q.empty()){
           int y = q.front().first, x = q.front().second;
           q.pop();
           for(int dy = -2; dy <= 2; dy++){
               for(int dx = -2; dx <= 2; dx++){
                   int ny = y + dy, nx = x + dx;
                   if(seen[ny][nx])continue;
                   //if(abs(ny - y) < 2 && abs(nx - x) < 2)continue;
                   if(s2[ny][nx])continue;
                   if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
                   if(fld[ny][nx] != '#'){
                       if(dp[ny][nx] < 0)dp[ny][nx] = dp[y][x] + 1;
                       else dp[ny][nx] = min(dp[ny][nx], dp[y][x] + 1);
                       que.emplace(ny, nx);
                   }
               }
           }
       }
   }
   cout << dp[gy][gx] << endl;
   //rep(i, h){rep(j, w)cout << dp[i][j] << " ";cout << endl;}
}


Measured memory_bytes: 19708
#include <queue>
#include <iostream>
#include <algorithm>

int n, m;
long long ans = 0LL;

struct Job {
  int cost, reward;

  bool operator < (const Job &rhs) const {
    return cost < rhs.cost;
  }
} job[100005];
std::priority_queue<int> q;

int main(void) {
  int n, m;
  std::cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    std::cin >> job[i].cost >> job[i].reward;
  std::sort(job + 1, job + 1 + n);
  for (int i = 1, j = 1; i <= m; ++i) {
    while (job[j].cost <= i && j <= n) {
      q.push(job[j].reward);
      ++j;
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int H, A; cin >> H >> A;
  cout << (H+A-1) / A << endl;
}


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

class Main {

    public static void main(String[] args)  {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();
	int d[] = new int[N];
	for (int i = 0; i < N; i++)
	    d[i] = sc.nextInt();

	Arrays.sort(d);
	if (d[(N / 2) - 1] == d[N / 2])
	    System.out.println(0);
	else
	    System.out.println(d[N / 2] - d[(N / 2) - 1]);
    }
}

Measured memory_bytes: 51228
def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    S = sum(A)

    MIN = float('inf')
    P = 0
    Q = S
    for a in range(len(A)-1):
        P += A[a]
        Q -= A[a]
        dif = abs(P-Q)
        MIN = min(MIN, dif)

    print(MIN)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


Measured memory_bytes: 24812
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,k,j,data[7],wk,flg,da[7],l,f;
	for(i=1;i<=6;i++)	scanf("%d",&da[i]);
	for(i=1;i<=6;i++)	scanf("%d",&data[i]);	
	flg=0;
	for(i=0;i<4;i++)	{
		wk=data[1];
		data[1]=data[2];
		data[2]=data[6];
		data[6]=data[5];
		data[5]=wk;
		for(j=0;j<4;j++)	{
			wk=data[1];
			data[1]=data[4];
			data[4]=data[6];
			data[6]=data[3];
			data[3]=wk;
			for(k=0;k<4;k++)	{
				wk=data[2];
				data[2]=data[3];
				data[3]=data[5];
				data[5]=data[4];
				data[4]=wk;
				f=1;
				for(l=1;l<=6;l++)	{
					if(data[l]!=da[l])	{
						f=0;	break;
					}
				}
				if(f==1)	{
					flg=1;
					j=4;	k=4;	i=4;
				}
			}
		}
	}
	if(flg==1)	printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1012
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

string pattern[4] = { "dream", "dreamer", "erase", "eraser" };

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

	string S;
	cin >> S;

	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; i++)
	{
		reverse(pattern[i].begin(), pattern[i].end());
	}

	int curr = 0;
	while (curr < S.size())
	{
		bool check = false;
		for (int i = 0; i < 4; i++)
		{
			int find_idx = S.find(pattern[i], curr);
			if (find_idx == curr)
			{
				curr = find_idx + pattern[i].size();
				check = true;
				break;
			}
		}

		if (!check)
		{
			cout << "NO";
			return 0;
		}
	}
	
	cout << "YES";

	return 0;
}

Measured memory_bytes: 512
N,K=map(int,input().split())
D=[int(x) for x in input().split()]
kazu=[9,8,7,6,5,4,3,2,1,0]
for item in D:
  kazu.remove(item)
p=[]
m=len(str(N))
for i in range(m):
  p.append(kazu[0]*(10**i))
p.sort(reverse=True)
j=0
while j<m:
  for i in range(1,len(kazu)):
    if sum(p)-p[j]+kazu[i]*(10**(m-j-1))>=N:
      p[j]=kazu[i]*(10**(m-j-1))
    else:
      break
  j+=1
if sum(p)<N:
  if kazu[-1]!=0:
    ans=0
    for i in range(m+1):
      ans+=kazu[-1]*(10**i)
  else:
    ans=kazu[-2]*(10)**m
else:
  ans=sum(p)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <deque>
#include <algorithm>
#include <time.h>

using namespace std;
int cnt,n,x;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=4;i++)
	{
		x=n%10;
		if(x==2)
			cnt++;
		n=n/10;
	}
	printf("%d",cnt);
	return 0;
}/*
1
5 4 5
 3  4  3  4
 5  5 -1  5
-1  4  5  5
 5  5  4  2
 1 -1  2  4
 
1 3 1 1
3 2 3 3
4 4 4 5
8 9 9 5
7 2 6 3*/

Measured memory_bytes: 256
a,b,k = map(int,input().split())
if k*2 >= b-a+1:
    for i in range(a,b+1):
        print(i)

else:
    for i in range(a,a+k):
        print(i)

    for j in range(b-k+1,b+1):
        print(j)

Measured memory_bytes: 3060
/* 
      Life before Death
      Strength before Weakness
      Journey before Destination
*/
                           
#include <bits/stdc++.h>
using namespace std;
                 
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for (ll i=n;i>a;i--)
#define te ll t; std::cin >> t; while(t--)
#define SZ 500010
//# define M_PIl  3.141592653589793238462643383279502884L 
/*------Just DO IT--------------------------------------*/

ll solve(){
   ll s;
   cin>>s;
   if(s==25) cout<<"Christmas "<<endl;
      if(s==24) cout<<"Christmas Eve"<<endl;

   if(s==23) cout<<"Christmas Eve Eve"<<endl;

   if(s==22) cout<<"Christmas Eve Eve Eve"<<endl;

  }

int main() {
  fastio;
   solve();
}

Measured memory_bytes: 256