akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

constexpr int SIZE = 110000;

// Does coordinate compression.
// Arguments:
// - raw_xs: Values to compress.
// Returns:
// - xs: Compressed values.
// - to_raw: A mapping from a compressed value to a raw value.
// Verified: CF573Div1D
tuple<vector<int>, vector<int>> Compress(const vector<int>& raw_xs) {
  unordered_set<int> raw_x_set(raw_xs.begin(), raw_xs.end());
  vector<int> to_raw(raw_x_set.begin(), raw_x_set.end());
  sort(to_raw.begin(), to_raw.end());
  unordered_map<int, int> to_index;
  for (int i = 0; i < to_raw.size(); i++) {
    to_index[to_raw[i]] = i;
  }
  vector<int> xs;
  for (int raw_x : raw_xs) {
    xs.push_back(to_index[raw_x]);
  }
  return make_tuple(xs, to_raw);
}

struct Edge {
  int from, to;
};

vector<vector<int>> ConnectedComponents(const vector<vector<Edge>>& graph) {
  int n = graph.size();
  vector<vector<int>> components;
  vector<int> visited(n);

  function<void(int)> dfs = [&](int v) {
    if (visited[v]) return;
    visited[v] = true;
    components[components.size() - 1].push_back(v);
    for (auto e : graph[v]) {
      if (visited[e.to]) continue;
      dfs(e.to);
    }
  };

  for (int s = 0; s < n; s++) {
    if (visited[s]) continue;
    components.push_back(vector<int>());
    dfs(s);
  }
  return components;
}

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

  int n;
  cin >> n;
  vector<int> raw_xs(n), raw_ys(n);
  for (int i = 0; i < n; i++) {
    cin >> raw_xs[i];
    cin >> raw_ys[i];
  }
  vector<int> xs, to_raw_xs, ys, to_raw_ys;
  tie(xs, to_raw_xs) = Compress(raw_xs);
  tie(ys, to_raw_ys) = Compress(raw_ys);

  int x_size = to_raw_xs.size();
  int y_size = to_raw_ys.size();
  vector<vector<Edge>> graph(x_size + y_size);
  for (int i = 0; i < n; i++) {
    int v1 = xs[i];
    int v2 = ys[i] + x_size;
    graph[v1].push_back(Edge({v1, v2}));
    graph[v2].push_back(Edge({v2, v1}));
  }
  // cout << "HOGE 1" << endl;
  vector<vector<int>> components = ConnectedComponents(graph);
  // cout << "HOGE 2" << endl;
  int64 count = 0;
  for (const auto& component : components) {
    int64 left_count = count_if(
        component.begin(), component.end(),
        [x_size] (int i) { return i < x_size; });
    int64 right_count = component.size() - left_count;
    count += left_count * right_count;
  }
  int64 answer = count - n;
  cout << answer << endl;
}


Measured memory_bytes: 11912
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            System.Threading.Thread.Sleep(1000);
        }

        public void Solve(ConsoleInput cin)
        {
            int[] list = cin.ReadIntArray(3);
            int b = cin.ReadInt;

            Array.Sort(list);

            int sum = list[2];
            for (int i = 0; i < b; i++)
            {
                sum = sum * 2;
            }

            sum += list[0] + list[1];

            Console.WriteLine(sum);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
vector<int> gra[100001];
int O[100001],dis[100001],aimc[100001],color[100001],alr_mxdis[100001];
void dfs(int wil,int lefdis,int aim)
{
	if(lefdis<=alr_mxdis[wil])
		return;
	alr_mxdis[wil]=lefdis;
	if(!color[wil])
		color[wil]=aim;
	if(!lefdis)
		return;
	for(int i=0;i<gra[wil].size();i++)
		dfs(gra[wil][i],lefdis-1,aim);
}
int main()
{
	int n,m,tim,i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
		alr_mxdis[i]=-1;
	for(i=1;i<=m;i++)
	{
		int s,e;
		scanf("%d%d",&s,&e);
		gra[s].push_back(e);
		gra[e].push_back(s);
	}
	scanf("%d",&tim);
	for(i=1;i<=tim;i++)
		scanf("%d%d%d",O+i,dis+i,aimc+i);
	for(i=tim;i;i--)
		dfs(O[i],dis[i],aimc[i]);
	for(i=1;i<=n;i++)
		printf("%d\n",color[i]);
	return 0;
}
/*1
7 7
1 2
1 3
1 4
4 5
5 6
5 7
2 3
2
6 1 1
1 2 2
*/
/*2
14 10
1 4
5 7
7 11
4 10
14 7
14 3
6 14
8 11
5 13
8 3
8
8 6 2
9 7 85
6 9 3
6 7 5
10 3 1
12 9 4
9 6 6
8 2 3
*/

Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,st,ed) for(int i = st; i < ed; ++i)
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
const ll mod = 1e5+3;
const ll N = 1e5 + 200;
const ll INF = 9999999999999;
const double eps = 1e-7;

int par[N];
int roots(int v){return par[v] < 0 ? v : (par[v] = roots(par[v]));}
void merge(int x, int y ){
    if( (x = roots(x)) == (y = roots(y))) return;
    if(par[y] < par[x]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
}
vector<ll> v[N],v2[N];
int num[N];
int main(){
    int n,m,k;
    memset(par, -1, sizeof(par));
    cin>>n>>m>>k;
    int x,y;
    rep(i,m){
        cin>>x>>y;
        v[x].pb(y);
        merge(x,y);
        v[y].pb(x);
    }
    rep(i,k){
        cin>>x>>y;
        v2[x].pb(y);
        v2[y].pb(x);
    }
    for(int i = 1; i <= n; i++){
        num[roots(i)]++;
    }
    for(int i = 1; i <= n; i++){
        ll tmp = num[roots(i)] - 1;
        int len = v[i].size();
        rep(j,len){
            if(roots(i) == (roots(v[i][j]))){
                tmp--;
            }
        }
        len = v2[i].size();
        rep(j,len){
            if(roots(i) == (roots(v2[i][j]))){
                tmp--;
            }
        }
        cout<<tmp<<" ";
    }
    return 0;
}

Measured memory_bytes: 13428
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int A[100010];
ll ruis[100010];

int main() {
	ll N, M;
	cin >> N >> M;
	for(int i=0; i<N; ++i) cin >> A[i];
	sort(A, A+N);
	A[N]=200010;
	int ok=0, ng=200010;
	while(ok+1<ng){
		int mid=(ok+ng)/2, now=N;
		ll sum=0;
		for(int i=0; i<N; ++i){
			while(now>0){
				if(A[i]+A[now-1]>=mid) --now;
				else break;
			}
			sum += N-now;
		}
		if(M<=sum) ok=mid;
		else ng=mid;
	}
	for(int i=0; i<N; ++i) ruis[i+1]=ruis[i]+A[i];
	int nn=N;
	ll cnt=0, ans=0;
	for(int i=0; i<N; ++i){
		while(nn>0){
			if(A[i]+A[nn-1]>=ok) --nn;
			else break;
		}
		ans += ruis[N]-ruis[nn]+A[i]*(N-nn);
		cnt += N-nn;
	}
	ans -= (cnt-M)*ok;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals(b)){
			System.out.print("H");
		}else{
			System.out.print("D");
		}
	}
}

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

int main (void) {
    int r, c, sum;
    int **sp;

    scanf ("%d %d", &r, &c);
    sp = (int **) malloc (sizeof(int *)*(r+1));
    for (int i=0; i<r+1; i++) 
        sp[i] = (int *) malloc (sizeof(int)*(c+1));

    for (int i=0; i<r; i++)
        for (int j=0; j<c; j++)
            scanf ("%d", &sp[i][j]);
    
    for (int i=0; i<r; i++) {
        sum=0;
        for (int j=0; j<c; j++)
            sum += sp[i][j];
        sp[i][c] = sum;
    }

    for (int i=0; i<c+1; i++) {
        sum=0;
        for (int j=0; j<r; j++)
            sum += sp[j][i];
        sp[r][i] = sum;
    }

    for (int i=0; i<r+1; i++) {
        for (int j=0; j<c+1; j++) {
            if (j==c) printf ("%d\n", sp[i][j]);
            else printf ("%d ", sp[i][j]);
        }
    }  

    for (int i=0; i<r+1; i++) 
        free(sp[i]);
    free(sp);

    return 0;
}


Measured memory_bytes: 2108
flag = False
n = int(input())
t = [[0,0,0]]
for i in range(n):
    t.append( [int(x) for x in input().split()])
 
for  i in range(n):
    if (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2])) /  (t[i+1][0]-t[i][0]) > 1:
            flag = False
            break
    elif (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))   / ( t[i+1][0]-t[i][0])  == 1:
            flag = True
            continue
    else:
            if not (( t[i+1][0]-t[i][0]) - (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))  )  &1:
                flag = True
                continue
            else:
                flag = False
                break
if flag:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 62296
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define print(x) cout << x << endl
#define ps(x,y) fixed<<setprecision(y)<<x
#define pprint cout<<"Case #"<<tt<<": ";
const int mod = 1e9+7;
const int N = 2e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}

struct Compare {
    bool operator () (pii A, pii B) {
        return A.first > B.first;
    }
};
 struct tri{
   int x,y,z;
 };
 struct cmp{
bool operator ()(tri a,tri b){
    if(a.x==b.x)
        return a.y>b.y;
    return a.x<b.x;

}};
bool comp(pii a,pii b){
    if(a.first>b.first) return true;
    else if(a.first==b.first) return a.second<b.second;
    else return false;

}
int binarySearch(vector<int>nums, int lo, int hi, int target) {
        while (lo < hi) {
            int mid = (lo + hi)/2;
            if (nums[mid] <= target) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        return lo;
    }

void solve() {

    int t = 1;
    //cin >> t;
    while(t--){
        string s,t;
        cin>>s>>t;
        int ans=INT_MAX;
        for(int i=0;i<=s.size()-t.size();i++){
                int k=0,l=0;
            for(int j=i;j<i+t.size();j++){
                    //cout<<s[j]<<t[l]<<endl;
                if(s[j]!=t[l]) k++;
            l++;
            }
            //cout<<k<<endl;
            ans=min(ans,k);
        }
        cout<<ans;

    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);1

    freopen("output.txt", "w", stdout);
    #endif*/

    solve();

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int X, t;
    cin >> X >> t;
    cout << (X - t>=0?X-t:0) << endl;
}

Measured memory_bytes: 256
n = int(input())
A = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

for i in range(n):
    name = input()
    if name[0] in A:
        A[name[0]] += 1

m = A['M']
a = A['A']
r = A['R']
c = A['C']
h = A['H']
    
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)

Measured memory_bytes: 3064
n,m = map(int,input().split())
A = [input() for _ in range(n)]
B = ''.join([input() for _ in range(m)])
na = n - (m-1)
ans = 'No'

for i in range(na):
    A1 = ''.join([a[i:i+m] for a in A])
    if B in A1:
        ans = 'Yes'
        break
        
print(ans)

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cs: Vec<char> = s.chars().collect();
    let ans = if cs[0] == cs[1] || cs[1] == cs[2] || cs[2] == cs[3] {
        "Bad"
    } else {
        "Good"
    };
    println!("{}", ans);
}


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

#define ll long long

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll a, b, k;
	cin >> a >> b >> k;
	
	ll p= a-min(a,k), q=b;
	ll rem= k-min(a,k);
	if(rem) q=b-rem;
	
	cout << p << " " << max(0LL,q) << endl;
	
	return 0;
}


Measured memory_bytes: 256
//
// Created by yutaro_nishikawa on 2020/07/29.
//

#include <iostream>

using namespace std;
static const int MAX = 100;

int main() {
    int A[MAX], n;

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

    int cnt = 0;
    int flag = 1;
    for (int j = 0; flag; ++j) {
        flag = 0;
        for (int i = n - 1; i >= j + 1; --i) {
            if (A[i] < A[i - 1]) {
                int tmp = A[i - 1];
                A[i - 1] = A[i];
                A[i] = tmp;
                flag = 1;
                ++cnt;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;

}


Measured memory_bytes: 3096
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; ++i)
    cin >> A[i];
  
  int count = 0;
  while(1) {
    int min_idx = -1;
    for(int i=0; i<N; ++i) {
      if(A[i]%2 != 0) {
        continue;
      }
      if(min_idx == -1 || A[i] < A[min_idx])
        min_idx = i;
    }
    if (min_idx == -1) {
      break;
    }

    while(A[min_idx]%2==0) {
      ++count;
      A[min_idx] /= 2;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
def gcd2(x, y):
    if x % y == 0:
        return y
    else:
        return gcd2(y, x % y)

def gcd3(x, y, z):
    return gcd2(gcd2(x, y), z)

def pat(x, y, z):
    p = len(set([x, y, z]))
    if p == 1:
        return 1
    elif p == 2:
        return 3
    else:
        return 6

K = int(input())
S = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            S += gcd3(i, j, k) * pat(i, j, k)
print(S)


Measured memory_bytes: 9208
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    long long int n,k,a;
    scanf("%lld %lld",&n,&k);
    if(n==k)
    printf("0\n");
    else if(n<k)
    {
        if(n<(k-n))
        printf("%lld\n",n);
        else
        printf("%lld\n",(k-n));
    }
    else
    {
        a=n%k;
        if(a<(k-a))
        printf("%lld\n",a);
        else
        printf("%lld\n",(k-a));
    }
}

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

#define MOD 998244353
#define ll long long
int A, B, C, D;
ll dp[3030][3030];

int main(){

    int ret;
    
    ret = scanf("%d %d %d %d", &A, &B, &C, &D);
    if(ret == EOF){
        return -1;
    }

    for (int i = A; i <= C; i++)
    {
        for (int j = B; j <= D; j++){
            if(i==A && j == B){
                dp[i][j] = 1;
                continue;
            }
            dp[i][j] = i * dp[i][j - 1] % MOD + j * dp[i - 1][j] % MOD - (i - 1) * (j - 1) * dp[i - 1][j - 1] % MOD;
            dp[i][j] %= MOD;
        }
    }

    ll ans = dp[C][D] + MOD;
    ans %= MOD;

    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 74836
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,avx2,mmx,abm")
#pragma GCC optimize("unroll-loops,inline")
#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

const int MAXN = 3010;
int n, s;
int a[MAXN];
int dp[MAXN];

signed main() {
	scanf("%d%d", &n, &s);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int ans = 0;
	for (int i = 0; i <= s; i++)
		dp[i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int w = s - a[i]; w >= 1; w--) {
			int nxt = w + a[i];
			dp[nxt] = add(dp[nxt], dp[w]);
		}
		int nxt = a[i];
		if (nxt <= s) dp[nxt] = add(dp[nxt], i);
		ans = add(ans, dp[s]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

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

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

vector<int> digit;
ll memo[201][4][2];
int k, n;

ll dp(int idx, int cnt, int tight) {
    if (idx == n && cnt == k) {
        return 1;
    }
    if (cnt > k || idx >= n){
        return 0;
    }
    if (memo[idx][cnt][tight] != -1){
        return memo[idx][cnt][tight];
    }
    int target = (tight? digit[idx] : 9);
    ll ret = 0;
    // cout << ret << endl;
    for (int x = 0; x <= target; x++) {
        int ntight = (x == digit[idx])? tight : 0;
        ret += dp(idx+1, cnt + (x > 0), ntight);
    }
    // cout << idx << " " << cnt <<" "<< tight << endl;
    // cout << ret << endl;
    memo[idx][cnt][tight] = ret;
    return ret;
}

int main() {

    string s;

    cin >> s >> k;
    n = s.size();
    for (int i = 0; i < s.size(); i++)
        digit.pb(s[i]-'0');

    // cout << n << endl;
    // cout << k << endl;
    memset(memo, -1, sizeof(memo));
    ll ans = dp(0,0,1);
    // cout << to_string(digit) << endl;
    // cout << (to_string(digit) == s) << endl;

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

Measured memory_bytes: 256
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
D = inp.shift() * 1
N = inp.shift() * 1
if (D == 0) {
    if (N == 100) {
        ans = N + 1
    } else {
        ans = N
    }
} else {
    if (N == 100) {
        ans = Math.pow(100, D) * (N + 1)
    } else {
        ans = Math.pow(100, D) * N
    }
}
console.log(ans)

Measured memory_bytes: 7372
#include <stdio.h>
#include <math.h>
#define M 100
#define o 1000000

int p;
int tree[M][M];

int weight(){
  int a,i,j,cost,now[M],g[M],oya[M];
  int count=0;

  for(i=0;i<p;i++){
    g[i]=o;
    oya[i]=-1;
    now[i]=0;
  }

  g[0]=0;

  while(1){
    cost=o;
    a=-1;
      for(i=0;i<p;i++){
	if(cost>g[i]&&now[i]!=2){
	  a=i;
	  cost=g[i];
	}
      }
    
    if(a==-1) break;
    now[a]=2;
    for(i=0;i<p;i++){
      if(now[i]!=2 && tree[a][i]!=o){
	if(tree[a][i]<g[i]){
	  g[i]=tree[a][i];
	  oya[i]=a;
	  now[i]=1;
	}
      }
    }
  }

  for(i=0;i<p;i++){
    if(oya[i]!=-1) count+=tree[i][oya[i]];
  }

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

     

int main(){
  int i,j;

  scanf("%d",&p);

  for(i=0;i<p;i++){
    for(j=0;j<p;j++){
      scanf("%d",&tree[i][j]);
      if(tree[i][j]==-1){
	tree[i][j]=o;
      }
    }
  }

  weight();

  return 0;	
}



Measured memory_bytes: 2052
package main

import "fmt"

func main() {
	m := make(map[string]int)
	res := [4]string{"AC", "WA", "TLE", "RE"}
	n, s := 0, ""
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &s)
		m[s]++
	}
	for _, i := range res {
		fmt.Printf("%s x %d\n", i, m[i])
	}
}


Measured memory_bytes: 6324
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a < 6) {
        cout << 0 << endl;
    } else if (a < 13) {
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = (1e9);
int main(){
  int N;
  const int M = (1<<16);
  cin >> N;
  vector<int> DP(M,INF);
  DP[0] = 0;
  string color = "RGB";
  vector<int> H(N), W(N);
  for(int i = 0; i < N; ++i){
    cin >> H[i] >> W[i];
  }
  string C[4];
  for(int i = 0; i < 4; ++i) cin >> C[i];

  int AND[5][5][7][7][3], OR[5][5][7][7][3];
  for(int j = 0; j < N; ++j){
    for(int k = 0; k < 3; ++k){
      for(int l = 1-H[j]; l < 4; ++l){
        for(int m = 1-W[j]; m < 4; ++m){
          int a = M-1, o = 0;
          for(int h = max(-l,0); h < H[j]; ++h){
            for(int w = max(-m,0); w < W[j]; ++w){
              int x = l+h, y = m+w;
              if(x > 3 || y > 3 || x < 0 || y < 0) continue;
              if(C[x][y] == color[k]) o |= (1<<(4*x+y));
              else a &= ~(1<<(4*x+y));
            }
          }
          AND[H[j]][W[j]][l+3][m+3][k] = a;
          OR[H[j]][W[j]][l+3][m+3][k] = o;
        }
      }
    }
  }
  priority_queue< pair<int,int> > wait;
  wait.emplace(0,0);
  while(!wait.empty()){
    int c = -wait.top().first, i = wait.top().second;
    wait.pop();
    if(DP[i] < c) continue;
    DP[i] = c;
    if(i == M-1) break;
    for(int j = 0; j < N; ++j){
      for(int k = 0; k < 3; ++k){
        for(int l = 1-H[j]; l < 4; ++l){
          for(int m = 1-W[j]; m < 4; ++m){
            int i_ = i;
            i_ &= AND[H[j]][W[j]][l+3][m+3][k];
            i_ |= OR[H[j]][W[j]][l+3][m+3][k];
            if(DP[i_] <= DP[i]+1) continue;
            DP[i_] = DP[i]+1;
            wait.emplace(-c-1,i_);
          }
        }
      }
    }
  }
  cout << DP[M-1] << endl;
  return 0;
}



Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<ll> x(n), y(n), z(n);
  rep(i, n) cin >> x[i] >> y[i] >> z[i];

  ll ans = 0;
  rep(i, 2) rep(j, 2) rep(k, 2) {
    using t = pair<ll, int>;
    vector<t> v(n);
    rep(l, n) {
      ll X = (i == 0 ? x[l] : -x[l]);
      ll Y = (j == 0 ? y[l] : -y[l]);
      ll Z = (k == 0 ? z[l] : -z[l]);
      v[l] = t(X + Y + Z, l);
    }
    sort(all(v), greater<t>());
    vector<ll> tmp(3);
    rep(l, m) {
      int o = v[l].S;
      tmp[0] += x[o];
      tmp[1] += y[o];
      tmp[2] += z[o];
    }
    chmax(ans, abs(tmp[0]) + abs(tmp[1]) + abs(tmp[2]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int r;
    cin >> r;
    printf("%.3f\n", double(r * 2 * M_PI));
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int a,b;
    cin>>a>>b;
    if(a>=10 || b>=10){
        cout << -1 << endl;
        return 0;
    }
    cout << a*b << endl;
    return 0;
}

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

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int n;
long long a[maxn];
long long fact[maxn], inv[maxn];
long long val[maxn];

void brute() {
    int id[n], cnt[n];
    for (int i = 0; i < n; i++) id[i] = i, cnt[i] = 0;
    int vs[n];
    int ans = 0;
    do {
	for (int i = 0; i < n; i++) vs[i] = 0;
	for (int i = 0; i < n; i++) {
	    int cur = id[i];
	    while (cur < n && !vs[cur]) {
		ans += a[cur + 1];
		cnt[cur]++;
		cur++;
	    }
	    cur = id[i] - 1;
	    while (cur >= 0 && !vs[cur]) {
		ans += a[cur + 1];
		cnt[cur]++;
		cur--;
	    }
	    vs[id[i]] = 1;
	}
    } while (next_permutation(id, id + n));
    for (int i = 0; i < n; i++) {
	cout << cnt[i] << ' ';
    }
    cout << endl;
    cout << ans << endl;
}

long long power_mod(long long a, long long b, long long mod) {
    long long res = 1;
    while (b) {
	if (b % 2) res = res * a % mod;
	a = a * a % mod;
	b >>= 1;
    }
    return res;
}

long long C(int n, int k) {
    if (k > n) return 0;
    return fact[n] * inv[n - k] % mod * inv[k] % mod;
}

int main() {
    fact[0] = inv[0] = 1;
    for (int i = 1; i < maxn; i++) {
	fact[i] = fact[i - 1] * i % mod;
	inv[i] = power_mod(fact[i], mod - 2, mod);
    }

    cin >> n;

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

    for (int i = 0; i < n; i++) {
	val[i] = C(n, i + 1) * fact[i] % mod * fact[n - i - 1] % mod;
    }

    long long cur = 0;
    for (int i = 0; i < n; i++) {
	cur = (cur + val[i]) % mod;
    }

    long long ans = 0;
    for (int i = n; i >= 1; i--) {
	ans = (ans + cur * a[i - 1]) % mod;
	cur = (cur - val[i - 1] + val[n - i + 1] + mod) % mod;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3328
n = int(input())
a = [int(i) for i in input().split()]
ans = 0

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

for key, value in dic.items():
    if key-value > 0:
        ans += value
    else:
        ans += value-key

print(ans)


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

int main() {
    ll x;
    cin>>x;
    ll res=100,count=0;
    while(res<x) {
        res*=1.01;
        count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int		main()
{
	int		N, i;

	i = 1;
	scanf("%d\n", &N);
	while (++i < 10)
	{
		if (((N / i) < 10 && !(N % i)) || N == 1)
		{
			printf("Yes\n");
			return (0);
		}
	}
	printf("No\n");
	return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

using vi = vector<int>;
using vll = vector<ll>;
#define allOf(x) (x).begin(), (x).end()

template <typename P, typename Q>
ostream&operator<<(ostream&os, const pair<P, Q>&p)
{return os << '(' << p.first << ", " << p.second << ')';}
template <typename K, typename V>
ostream&operator<<(ostream&os, const map<K, V>&v)
{os << '['; for(const auto&it:v) (os << it) << ", "; return os << ']';}
template <typename T> ostream&operator<<(ostream&os, const set<T>&v)
{os << '['; for(const auto&it:v) (os << it) << ", "; return os << ']';}
template <typename T> ostream&operator<<(ostream&os, const vector<T>&v)
{os << '['; for(const auto&it:v) os << it << ", "; return os << ']';}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  string s, t; cin >> s >> t;
  vector< char > perm(256, 0), rev(256, 0);
  for(size_t i=0; i<s.length(); i++) {
    if( perm[s[i]] != 0 ) {
      if( perm[s[i]] != t[i] or rev[t[i]] != s[i] ) {
	cout << "No" << nl;
	return 0;
      }
    } else {
      perm[s[i]] = t[i];
      if( rev[t[i]] != 0 ) {
	cout << "No" << nl;
	return 0;
      }
      rev[t[i]] = s[i];
    }
  }
  cout << "Yes" << nl;

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


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

using namespace std;

typedef long long ll;

int main() {
    ll ans = 0;
    ll n, m;   cin >> n >> m;
    pair<ll,ll> *p = new pair<ll,ll>[n];
    for (int i = 0; i < n; i++)
        cin >> p[i].first >> p[i].second;
    sort(p, p+n);

    priority_queue<ll> p_que;

    ll j = 0;
    for (int i = 1; i <= m; i++) {
        while (j < n && p[j].first <= i) {
            p_que.push(p[j].second);
            j++;
        }
        if (!p_que.empty()) {
            ans += p_que.top();
            p_que.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n,k,q,x,cnt[maxn];
void solve(){
	rep(i,1,n){
		if(k - q + cnt[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k >> q;
	rep(i,1,q){
		cin >> x;
		cnt[x]++;
	}
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 1408
from bisect import bisect,bisect_left
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
ans=0
for b in B:
  i=bisect_left(A,b)
  j=bisect(C,b)
  ans+=i*(N-j)
print(ans)

Measured memory_bytes: 29308
#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }

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

  ll res = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 15 == 0) continue;
    else if (i % 3 == 0) continue;
    else if (i % 5 == 0) continue;
    else res += i;
  }
  cout << res << endl;


}


Measured memory_bytes: 3648
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int main(){
	fastio;
	string s;
	R(s);
	if(s[s.length()-1]=='s'){
		cout<<s<<"es"<<endl;
	}
	else{
		cout<<s<<"s"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b;

    cin >> a >> b;

    cout << max(0, a - 2 * b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define L 57

int main(void) {
  int n, m;
  char a[L][L], b[L][L];

  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; i++)
    scanf("%s", a[i]);

  for (int i = 0; i < m; i++)
    scanf("%s", b[i]);

  for (int i = 0; i < n - m + 1; i++)
    for (int j = 0; j < n - m + 1; j++) {
      for (int k = 0; k < m; k++)
        for (int l = 0; l < m; l++)
          if (a[i+k][j+l]  != b[k][l])
            goto loopend;

      printf("Yes");
      return 0;

loopend:
      continue;
    }

  printf("No");
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
A= list(map(int, input().split()))

count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)

Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = a + b;
    int f = c + d;
    if(e > f){
        cout << "Left" << endl;
    }else if(e < f){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }

    return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 2e5 + 5;
int a[maxn], b[maxn];
ll pref1[maxn], pref2[maxn];

int main(){
	int n,m;
	ll k;
	scanf("%d %d %lld",&n,&m,&k);
	int i,j;
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		pref1[i] = a[i];
		if(i){
			pref1[i] += pref1[i-1];
		}
	}

	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
		pref2[i] = b[i];
		if(i){
			pref2[i] += pref2[i-1];
		}
	}

	int cnt = 0;
	for(i=0;i<n;i++){
		if(pref1[i] > k){
			break;
		}
		int ans = i+1;
		ll sisa = k - pref1[i];
		int idx = upper_bound(pref2, pref2+m, sisa) - pref2;
		ans += idx;
		cnt = max(cnt, ans);
	}

	for(i=0;i<m;i++){
		if(pref2[i] > k){
			break;
		}
		int ans = i+1;
		ll sisa = k - pref2[i];
		int idx = upper_bound(pref1, pref1+n, sisa) - pref1;
		ans += idx;
		cnt = max(cnt, ans);
	}
	printf("%d\n",cnt);
	
	return 0;
};

Measured memory_bytes: 8484
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N,M,X;
		long min = Long.MAX_VALUE;
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		N = line[0];
		M = line[1];
		X = line[2];

		int[][] books = new int[N][M + 1];
		int[] skillSum = new int[M];
		long costLet = 0;
		for (int i = 0; i < books.length; i++) {
			books[i] = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		}

		for (int i = 0; i < (1 << N) ; i++) {
			for (int j = 0; j < N; j++) {
				if (((i >>j) & 1) == 1 ) {
					costLet += books[j][0];
					for (int k = 1; k <= M; k++) {
						skillSum[k - 1] += books[j][k];
					}
				}
			}
			for (int j = 0; j < M; j++) {
				if (skillSum[j] < X) {
					break;
				}
				if (j == M - 1 && costLet < min) {
					min =costLet;
				}
			}
			Arrays.fill(skillSum, 0);
			costLet = 0;
		}

		if (min == Long.MAX_VALUE) {
			System.out.println(-1);
		}else {
			System.out.println(min);
		}

	}
}

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

class MP
{
public:
    vector<long long> pattern;
    long long plen;
    vector<long long> table;
    MP(const vector<long long>& s) : pattern(s), plen((long long)pattern.size()), table(plen + 1){
        table[0] = -1;
        long long j = -1;
        for(long long i = 0; i < plen; ++i){
            while(j >= 0 && pattern[i] != pattern[j]){
                j = table[j];
            }
            table[i+1] = ++j;
        }
    }
    void search(const vector<long long>& text, vector<long long>& res){
        long long head = 0, j = 0, tlen = (long long)text.size();
        while(head + j < tlen){
            if(pattern[j] == text[head + j]) {
                if(++j == plen){
                    res.push_back(head);
                    head = head + j - table[j];
                    j = table[j];
                }
            }else{
                head = head + j - table[j];
                if(j) j = table[j];
            }
        }
    }
    void minimum_cycle(vector<long long>& res){
	    res.resize((long long)pattern.size());
	    for(long long i = 0; i < (long long)pattern.size(); ++i){
	    	res[i] = i + 1 - table[i+1];
	    }
    }
};

int main(){
    //input
    long long N;
    cin >> N;
    long long a[N], b[N];
    long long i;
    for(i=0; i<N; i++){
        cin >> a[i];
    }
    for(i=0; i<N; i++){
        cin >> b[i];
    }

    //exceptional
    if(N==1){
        cout << 0 << " " << (a[0]^b[0]) << endl;
        system("pause");
        return 0;
    }

    //calc
    vector<long long> AA,BB;
    for(i=0; i<N-1; i++){
        AA.push_back(a[i]^a[i+1]);
    }
    AA.push_back(a[N-1]^a[0]);
    for(i=0; i<N-1; i++){
        AA.push_back(a[i]^a[i+1]);
    }
    AA.push_back(a[N-1]^a[0]);
    for(i=0; i<N-1; i++){
        BB.push_back(b[i]^b[i+1]);
    }
    MP BBBB(BB);
    vector<long long> adj;
    BBBB.search(AA,adj);
    for(i=0; i<adj.size(); i++){
        if(adj[i]>=N) break;
        cout << adj[i] << " " << (a[adj[i]]^b[0]) << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 18712
n = int(input())
takoyaki = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i,n):
        if i == j:
            pass
        else:
            #print(takoyaki[i],takoyaki[j])
            ans += takoyaki[i]*takoyaki[j]
print(ans)

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

typedef long long ll;
#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++)

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

ll A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z;

//* ?????????n??????????????\??????????????????????????????????????????
template <typename T>
vector<T> INP(ll n)
{
	vector<T> x;
	REP(i, n) {
		T tmp; cin >> tmp;
		x.push_back(tmp);
	}
	return x;
}
//* n??????1????????????????????\?????????????????????????????¨??????????????????
vector<char> SPRIT_STRING(ll n)
{
	string str; cin >> str;
	vector<char> cs(n);
	REP(i, n) cs[i] = str[i];
	return cs;
}
//* ??§?¨?nx, ny???Width,Height?????????????????????????????????????????§??????
inline bool rangeCheck2D(int nx, int ny, int Width, int Height)
{
	return nx >= 0 and nx < Width and ny >= 0 and ny < Height;
}
//* ?´???°?????? is_prime<unsigned>(N)
template<typename T, std::enable_if_t<std::is_unsigned<T>::value, std::nullptr_t> = nullptr>
bool is_prime(const T n) {
	if (n < 4) return n == 2 || n == 3;
	if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
	for (T i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
	return true;
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2007
namespace makePurseLight {
	void makePurseLight()
	{
		cin >> N;
		int n[] = { 500, 100, 50, 10 };
		while (true) {
			int num[4];
			REP(i, 4) cin >> num[3-i];
			int sum = 0;
			REP(i, 4) sum += n[i] * num[i];
			int ret = sum - N;
			vector<int> cnt(4);
			while (ret > 0) {
				REP(i, 4) if (ret >= n[i]) {
					ret -= n[i]; cnt[i]++;
					break;
				}
			}
			REP(i, 4) {
				int ri = 3 - i;
				int ans = num[ri] - cnt[ri];
				if (ans > 0) cout << n[ri] << " " << ans << endl;
			}
			cin >> N;
			if (N == 0)
				break;
			else
				cout << endl;
		}
	}
}

namespace kannondou {
	void kannondou()
	{
		cin >> N;
		while (N) {
			ll dp[30];
			dp[0] = 1; dp[1] = 2; dp[2] = 4;
			FOR(i, 3, N)
				dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
			ll day = dp[N - 1] / 10 + ((dp[N - 1] % 10 == 0) ? 0 : 1);
			ll year = day / 365 + ((day % 365) ? 0 : 1);
			cout << year + 1 << endl;
			cin >> N;
		}
	}
}

// CodeForces
namespace foxAndCardGame {
	void foxAndCardGame()
	{
		cin >> N;
		int nums[105][105];
		int in[105];
		REP(i, N) {
			int c; cin >> c;
			in[i] = c;
			REP(j, c) {
				cin >> nums[i][j];
			}
		}
		int cielA = 0, jiroA = 0;
		vector<int> odds;
		REP(i, N) {
			int n = in[i];
			REP(j, n / 2) cielA += nums[i][j];
			if (n % 2 == 0) {
				if (n > 1) FOR(j, n / 2, n) jiroA += nums[i][j];
			}
			else {
				if (n > 2) FOR(j, n / 2 + 1, n) jiroA += nums[i][j];
				odds.push_back(nums[i][n / 2]);
			}
		}
		sort(odds.rbegin(), odds.rend());
		REP(i, odds.size()) {
			if (i % 2 == 0)
				cielA += odds[i];
			else
				jiroA += odds[i];
		}
		cout << cielA << " " << jiroA << endl;
	}
}

int main()
{
	kannondou::kannondou();
	return 0;
}


Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mxn 100010
using namespace std;

int n,a[mxn];
bool cmp(int x,int y)
{
	return x>y;
}
void work(int id)
{
	int i,qaq=0;
	for(i=id+1;a[i]==id&&i<n;i++)	qaq^=1;
	if((a[id]-id)%2==1||qaq)	printf("First\n");
	else	printf("Second\n");
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]),a[i]--;
	sort(a,a+n,cmp); int i;
	for(i=0;i<n;i++)
		if(a[i+1]<i+1)
		{
			work(i);break;
		}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
ll r,ans=0;

void solve() {
  cin>>r;

  // vector<ll> w(n),v(n);

  // rep(i,0,n) cin >>w[i] >> v[i];

  print(2*r*M_PI);

  return;
}


Measured memory_bytes: 3804