akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    int[][] cell = new int[h][w];
    for (int i = 0; i < h; i++) {
      String row = sc.next();
      for (int j = 0; j < w; j++) {
        cell[i][j] = row.charAt(j) == '#' ? 1 : 0;
      }
    }
    int count = 0;
    for (int bi = 0; bi < (1 << h); bi++) {
      for (int bj = 0; bj < (1 << w); bj++) {
        int black = 0;
        for (int i = 0; i < h; i++) {
          for (int j = 0; j < w; j++) {
            if (((bi >> i) & 1) == 1 || ((bj >> j) & 1) == 1) continue;
            if (cell[i][j] == 0) continue;
            black++;
          }
        }
        if (black == k) count++;
      }
    }
    System.out.println(count);
  }
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int di[] = {1, 0, -1, 0};
    int dj[] = {0, 1, 0, -1};
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') continue;
            int cnt = 0;
            for (int di = -1; di <= 1; di++) {
                for (int dj = -1; dj <= 1; dj++) {
                    if (di == 0 && dj == 0) continue;
                    int ni = i + di, nj = j + dj;
                    if (0 <= ni && ni < H && 0 <= nj && nj < W && S[ni][nj] == '#') cnt++;
                }
            }
            S[i][j] = cnt + '0';
        }
    }
    rep(i, H) {
        cout << S[i] << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

g = [[] for _ in range(n)]

for u, v, w in uvw:
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])


WHITE = 0
GRAY = 1
BLACK = 2

ds = [0] * n
colors = [WHITE] * n


def dfs(u):
    if colors[u] == BLACK:
        return

    colors[u] = GRAY

    for v, w in g[u]:
        if colors[v] == WHITE:
            ds[v] = ds[u] + w
            dfs(v)

    colors[u] = BLACK


dfs(0)

for d in ds:
    print(d % 2)


Measured memory_bytes: 108116
import java.util.Scanner;
public class Main {
 private static Scanner sc;
 public static void main(String[] args){
  int i,x;
  sc = new Scanner(System.in);
  int n = sc.nextInt();
  for(i=3;i<=n;i++){
	  x=i;
	   if(n<3||n>10000)break;
     

	   if(x%3==0){
  	     System.out.print(" "+i);continue;
     }else if(x%10==3){
  	     System.out.print(" "+i);continue;
     }
      

      if(x>10 && x<=100){
    	  x=i;
          x/=10;
          if(x==3 && x%10!=0){
              System.out.print(" "+i);continue;
          }
      }
      
      else if(x>100 && x<=1000){
   	      x=i;
          x=x-(x/100)*100;
          x/=10;
          if(x==3 && x%10!=0){
       	   System.out.print(" "+i);continue;
          }
          x=i;
          x/=100;
          if(x==3 && x%100!=0){
       	   System.out.print(" "+i);continue;
          }
      }
      
      
      else if(x>1000 && x<=10000){
   	      x=i;
          x=x-(x/1000)*1000;
          x=x-(x/100)*100;
          x/=10;
          if(x==3 && x%10!=0){
       	   System.out.print(" "+i);continue;
          }
          x=i;
          x=x-(x/1000)*1000;
          x/=100;
          if(x==3 && x%100!=0){
       	   System.out.print(" "+i);continue;
          }
          x=i;
          x/=1000;
          if(x==3 && x%1000!=0){
       	   System.out.print(" "+i);continue;
          }
      }
  }
  

  System.out.println();
 }
}

Measured memory_bytes: 28880
#include<bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
    string s;
    cin >> s;
    int size = s.size();
    for(int i: irange(0, size, 2)) cout << s[i];
    cout << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 int main()
{
     int x,y,a,b=0;
     cin>>x>>y;
     int ans=1;
     for(int i=0;i<x;i++){
        cin>>a;
        b+=a;
        if(b<=y){
            ans++;
        }
     }
     cout<<ans<<endl;
}


Measured memory_bytes: 256
#ABC116-C
n = int(input())
h = list(map(int,input().split()))
kadan = [0 for _ in range(n)]
cnt = 0
tf = [False for _ in range(n)]

for i in range(1,10**5):
    cnt += 1
    #print('cnt:',cnt)
    #print('tf:',tf)
    #print('kadan:',kadan)
    flg = False
    for j in range(n):
        if tf[j] == False:
            flg = True
            if kadan[j] == h[j]:
                tf[j] = True
            else:    
                kadan[j] += 1
        elif tf[j] == True and flg == False:
            pass
        else:
            break
            
    if not False in tf:
        break
print(cnt-1)
        

Measured memory_bytes: 9196
import collections
import numpy as np
 
# = input()
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
#
 
A, B = map(int, input().split())
 
if 1 <= A <= 9 and 1 <= B <= 9:
  print(A * B)
else:
  print(-1)

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

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




  while(1){
      bool at=true;
      for(int i=2;i<x;i++){
          if(x%i==0){
              at=false;
               break;
          }
      }
      if(at) {
        break;
      }
      x++;
  }
  cout<<x<<endl;
  return 0;
}


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

bool cnt[106];
int main() {
	int n, x;
	cin >> x >> n;
	for(int i = 0, y; i < n; ++i)
		cin >> y, cnt[y] = 1;
	int ans = x, cur = 1e9;
	for(int i = 0; i < 205; ++i) {
		if(cnt[i])
			continue;
		if(abs(x - i) < cur)
			cur = abs(x - i), ans = i;
	}
	cout << ans;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 10000005;
const int MAX_M = 300;

int prime[MAX_N];
bool is_prime[MAX_N];

int sieve(int n)
{
	int p = 0;
	for(int i=0;i<=n;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j=2*i;j<=n;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

struct edge
{
	int to,cap,rev;
};

vector<edge> G[MAX_M];
int level[MAX_M];
int iter[MAX_M];

void add_edge(int from,int to,int cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s)
{
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front();
		que.pop();
		rep(i,G[v].size()){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f)
{
	if(v==t){
		return f;
	}
	for(int &i = iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t)
{
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0){
			return flow;
		}
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,INF)) > 0){
			flow += f;
		}
	}
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vec(n,0);
    rep(i,n){
        cin >> vec[i];
    }
    sort(all(vec));
    vector<int> b;
    b.pb(vec[0]);
    rep(i,n){
        if(i >= 1){
            if(vec[i] != vec[i-1]+1){
                b.pb(vec[i]);
            }
        }
        if(i < n-1){
            if(vec[i+1] != vec[i]+1){
                b.pb(vec[i]+1);
            }
        }
    }
    b.pb(vec[n-1]+1);
    vector<int> ev,od;
    rep(i,b.size()){
        if(b[i]%2 == 0){
            ev.pb(b[i]);
        }else{
            od.pb(b[i]);
        }
    }
    int hoge = sieve(vec[n-1]+1);
    int u = (int)ev.size();
    int v = (int)od.size();
    rep(i,ev.size()){
        add_edge(0,i+1,1);
    }
    rep(i,ev.size()){
        rep(j,od.size()){
            int diff = abs(ev[i]-od[j]);
            if(diff%2 == 1 && is_prime[diff]){
                add_edge(i+1,u+1+j,INF);
            }
        }
    }
    rep(i,od.size()){
        add_edge(u+i+1,u+v+1,1);
    }
    int res = max_flow(0,u+v+1);
    cout << res + (u-res)/2*2 + (v-res)/2*2 + (u-res)%2*3 << endl;
    return 0;
}


Measured memory_bytes: 14720
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = raw_input()
cnt = ans = 0
for c in S:
    if not c in 'ATCG':
        ans = max(cnt, ans)
        cnt = 0
    else:
        cnt += 1
print max(ans, cnt)

Measured memory_bytes: 2808
function Main(input) {
  input = input.split(" ");
  var k = Number(input[0]);
  var x = Number(input[1]);
  var floor = x-k+1;
  var ceiling = x+k-1;
  var output = "";
  
  if(floor<-10000){
    floor=-10000;
  }

  if(ceiling>10000){
    ceiling=10000;
  }

  for(var i = floor ; i<= ceiling ; i++){
    output = output + String(i) + " ";
  }

  output = output.trim();

  console.log(output);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int T[114];
int D[114];
int cnt[114];
int N;

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%d", &D[i]);
    cnt[D[i]]++;
  }

  if (N > 23) {
    puts("0");
    return 0;
  }

  if (cnt[0]) {
    puts("0");
    return 0;
  }
    

  if (N == 23) {
    bool ok = cnt[0] == 0;
    ok &= cnt[12] == 1;
    for (int i=1; i<=11; i++) {
      ok &= cnt[i] == 2;
    }
    if (ok) {
      puts("1");
    } else {
      puts("0");
    }
    return 0;
  }

  int lim = 1 << N;
  int ans = 0;
  for (int st=0; st<lim; st++) {
    vector<int> ts;
    int s = 114;
    ts.emplace_back(0);
    ts.emplace_back(24);
    for (int i=0; i<N; i++) {
      if (st >> i & 1) {
        T[i] = 24 - D[i];
      } else T[i] = D[i];
      ts.emplace_back(T[i]);
      ts.emplace_back(24+T[i]);
    }
    sort(ts.begin(), ts.end());
    for (int i=0; i<ts.size()-1; i++) {
      s = min(s, ts[i+1]-ts[i]);
    }
    ans = max(ans, s);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long long int a,b,ans = 0;
    cin >> a >> b;

    for(int i = 1;;i++){
        if((max(a,b)*i) % min(a,b) == 0){
            ans = max(a,b)*i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    double T[n+1];
    T[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> T[i];
        T[i] += T[i-1];
    }

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

    double ans = 0.0;
    double before = 0.0;
    for (double t = 0.5; t <= T[n]; t += 0.5) {
        double mn = 1234567.0;
        mn = min(mn, t);
        mn = min(mn, T[n] - t);

        for (int i = 0; i < n; i++) {
            if (t < T[i]) {
                mn = min(mn, v[i] + T[i] - t);
            } else if (t < T[i+1]) {
                mn = min(mn, v[i]);
            } else {
                mn = min(mn, v[i] + t - T[i+1]);
            }
        }

        ans += (before + mn) * 0.25;
        before = mn;
    }

    cout << fixed << setprecision(10) <<  ans << "\n";
    return 0;
}

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

# vec = [K for _ in range(N)]

vec = [0 for _ in range(N)]

for _ in range(Q):
    A = int(input())
#     for i in range(N):
#         vec[i] -= 1
    vec[A-1] += 1

ret = '\n'.join(['Yes' if K-Q+x > 0 else 'No' for x in vec])
print(ret)

Measured memory_bytes: 54048
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MX = 100005;

int X, Y, A, B, C;
int ps[MX], qs[MX], rs[MX];
vector<pll> as;

bool cmp(pll&a, pll&b){
	return a.first > b.first;
}

ll solve(){
	sort(as.begin(), as.end(), cmp);
	vector<pll> n[3]; 
	int nt = 0;
	ll res = 0;
	for(int i=0; i<as.size() && nt < X + Y; i++){
		int c = as[i].second, d = as[i].first;
		if(c == 0){
			n[0].push_back(as[i]);
			nt++;
			res += d;

		}else if(c == 1 && n[1].size()<X){
			n[1].push_back(as[i]);
			nt++;
			res += d;

		}else if(c == 2 && n[2].size()<Y){
			n[2].push_back(as[i]);
			nt++;
			res +=d;
		}
	}

	return res;
}


int main(){
	cin>>X>>Y>>A>>B>>C;
	for(int i=0; i<A; i++){
		cin>>ps[i];
		as.push_back(pll(ps[i], 1));
	}
	for(int i=0; i<B; i++){
		cin>>qs[i];
		as.push_back(pll(qs[i], 2));
	}
	for(int i=0; i<C; i++){
		cin>>rs[i];
		as.push_back(pll(rs[i], 0));
	}

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


Measured memory_bytes: 12648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }
//clang++ -std=c++11 -stdlib=libc++ 

int f(int n) {
  int ans =0;
  while (n>0 && !(n&1)) {
    n>>=1;
    ans++;
  }
  return ans;
}

int main() {
  int N,M; cin>>N>>M;
  vi A(N);
  rep(i,N) {
    cin>>A[i];
  }
  rep(i, N) {
    if (A[i]&1) {
      cout << 0 <<endl;
      return 0;
    }
    A[i] >>=1;
  }
  int t = f(A[0]);
  rep(i, N) {
    if (f(A[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    A[i] >>= t;
  }
  M >>= t;
  ll l=1;
  rep(i,N){
    l = lcm(l, A[i]);
    if (l>M) {
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = M / l;
  ans = (ans+1)/2;
  cout << ans << endl;
  return 0;
}

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

int main() {

	int n;
	int v[20];
	int c[20];

	cin >> n;

	for (int i = 0; i < n;i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] > c[i])
			ans += v[i] - c[i];
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int X = int.Parse(s[0]);
        int Y = int.Parse(s[1]);
        int Z = int.Parse(s[2]);
        Console.WriteLine((X - Z) / (Y + Z));
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0}; 
int H,W;
char data[55][55];

bool check_around(int y, int x){
  for(int i=0;i<4;i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(nx<0||nx>=W||ny<0||ny>=H) continue;
    if(data[ny][nx]=='#') return true;
  }
  return false;
}
       
  
int main(){
  cin >> H>>W;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
    	cin >> data[i][j];
    }
  }
  
  bool result=true;
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j]=='#'){
        bool OK = check_around(i, j);
        if(!OK) cnt++;
      }
    }
  }
  if(cnt==0)  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
  
}

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

using namespace std;

int N;
int T[202];
double V[202];
double M[50000];

int main() {
    cin >> N;
    int sum = 0;
    rep(i, 50000) M[i] = 2020;
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> V[i];
    rep(i, N) {
        T[i] *= 2;
        for (int x=sum; x<=sum+T[i]; ++x) M[x] = min(M[x], V[i]);
        sum += T[i];
    }
    M[0] = M[sum] = 0;
    rep(i, sum) M[i+1] = min(M[i+1], M[i]+0.5);
    for (int i=sum-1; i>=0; --i) M[i] = min(M[i], M[i+1] + 0.5);
    double R = 0;
    rep(i, sum) R += M[i] + M[i+1];
    printf("%.12lf\n", R/4.0);
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define N 10

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

int main(void){
    int a[N],i;
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,N,sizeof(int),compare);
    printf("%d\n%d\n%d\n",a[N-1],a[N-2],a[N-3]);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <climits>

using namespace std;

#define REP(a, b) for(int (a) = 0; (a) < (b); (a)++)

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

int main() {
        int n, m, a, b, c, d;
        vector<P> st, cp;
        cin >> n >> m;
        REP(i, n) {
                cin >> a >> b;
                st.push_back(make_pair(a, b));
        }
        REP(i, m) {
                cin >> c >> d;
                cp.push_back(make_pair(c, d));
        }
        REP(i, n) {
                int idx, maxd = INT_MAX;
                REP(j, m) {
                        int md = abs(st[i].first - cp[j].first) + abs(st[i].second - cp[j].second);
                        if (md < maxd) {
                                idx = j;
                                maxd = md;
                        }
                }
                cout << idx + 1 << endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
double len(double r);
double width(double r);

int main() {
  double r;
  cin >> r;

  cout << fixed << setprecision(6) << width(r) << " " << len(r) << endl;
  return 0;
}

double len(double r) {
  return 2 * r * M_PI;
}

double width(double r) {
  return r * r * M_PI;
}

Measured memory_bytes: 1288
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BAToZString {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    vector<int> a, z;
	    for(int i=0; i<s.length(); i++){
	        if(s[i] == 'A') a.push_back(i);
	        if(s[i] == 'Z') z.push_back(i);
	    }
	    out << z[z.size()-1] - a[0] + 1 << endl;
	}
};


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


Measured memory_bytes: 1364
import bisect
from itertools import product
I = lambda n: [int(input()) for _ in range(n)]
def f(S, x):
    p = bisect.bisect_left(S, x)
    return [S[p-1], S[p]]
g = lambda x, s, t: abs(x-s)+abs(s-t)
INF = 10**11
a, b, q = map(int, input().split())
S, T, X = [-INF]+I(a)+[INF], [-INF]+I(b)+[INF], I(q)
for x in X:
    min_ = INF
    for s, t in product(f(S, x), f(T, x)):
        min_ = min(min_, g(x, s, t), g(x, t, s))
    print(min_)

Measured memory_bytes: 80856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false;

struct town {
  bool done = false;
  vector<int> to;
};

void dfs(int i, vector<town>&towns, pii p) {
  towns[i].done = true;
  for (int nx: towns[i].to) {
    if ((!towns[nx].done) && (!(((p.first == i) && (p.second == nx)) || ((p.first == nx) && (p.second == i))))) dfs(nx, towns, p);
  }
  return;
}

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

  int n, m;
  cin >> n >> m;
  vector<town> towns(n);
  vector<pii> bridges(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    towns[a].to.emplace_back(b);
    towns[b].to.emplace_back(a);
    bridges[i] = pii(a, b);
  }

  int cnt = 0;
  for (pii p: bridges) {
    dfs(0, towns, p);
    for (int i = 0; i < n; i++) {
      if (!towns[i].done) {
        cnt++;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      towns[i].done = false;
    }
  }

  cout << cnt << endl;
}


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

int main(){
    int dice[7],i,x;
    char order[101];
    for(int i = 1;i < 7;i++){
        scanf("%d",&dice[i]);
    }
    scanf("%s",order);
    for(i = 0;i < strlen(order);i++){
        if(order[i] == 'N'){
            x = dice[1];
            dice[1] = dice[2];
            dice[2] = dice[6];
            dice[6] = dice[5];
            dice[5] = x;
        }else if(order[i] == 'S'){
            x = dice[5];
            dice[5] = dice[6];
            dice[6] = dice[2];
            dice[2] = dice[1];
            dice[1] = x;
        }else if(order[i] == 'W'){
            x = dice[1];
            dice[1] = dice[3];
            dice[3] = dice[6];
            dice[6] = dice[4];
            dice[4] = x;
        }else if(order[i] == 'E'){
            x = dice[4];
            dice[4] = dice[6];
            dice[6] = dice[3];
            dice[3] = dice[1];
            dice[1] = x;
        }
    }
    printf("%d\n",dice[1]);
    return 0;
}




Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  int dir = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      dir++;
    } else {
      dir--;
    }
    if (dir == -4)
      dir = 0;
    if (dir == 4) {
      dir = 0;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3200
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		h = scanner.nextInt();
		w = scanner.nextInt();
		n = scanner.nextInt();
		map = new char[h][w];
		for (int i = 0; i < h; i++)
			map[i] = scanner.next().toCharArray();
		dp = new int[3][h + 1][w + 1];
		for (int i = 1; i <= h; i++)
			for (int j = 1; j <= w; j++)
				for (int k = 0; k < 3; k++)
					dp[k][i][j] = dp[k][i - 1][j] + dp[k][i][j - 1]
							- dp[k][i - 1][j - 1] + (map[i - 1][j - 1] == c[k] ? 1
							: 0);
		ans = new int[3];
		StringBuilder builder = new StringBuilder();
		while (n-- > 0) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			for (int i = 0; i < 3; i++)
				ans[i] = dp[i][c][d] - dp[i][c][b] - dp[i][a][d] + dp[i][a][b];
			builder.append(ans[0]).append(' ').append(ans[1]).append(' ').append(ans[2]).append('\n');
		}
		System.out.print(builder);
	}

	int w, h, n;
	int[] ans;
	int[][][] dp;
	char[][] map;
	char[] c = { 'J', 'O', 'I' };

}

Measured memory_bytes: 167148
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
string d[4] = {"dream","erase","dreamer","eraser"};
int main(){
    rep(i,4)reverse(all(d[i]));

    string s;
    cin>>s;
    reverse(all(s));

    
    int c=0;
    while(c!=s.size()){
        if(s.size()>=5){
            string tmp = s.substr(c,5);
            if(tmp==d[0]||tmp==d[1]){
                c+=5;
                continue;
            }
        }
        if(s.size()>=6){
            string tmp = s.substr(c,6);
            if(tmp==d[3]){
                c+=6;
                continue;
            }
        }
        if(s.size()>=7){
            string tmp = s.substr(c,7);
            if(tmp==d[2]){
                c+=7;
                continue;
            }
        }
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 512
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mx = 0
sm = 0
for i in range(1,n):
    sm += a[i] - a[i-1]
    if a[i] - a[i-1] > mx:
        mx = a[i] - a[i-1]
print(k - max(mx,k-sm))

Measured memory_bytes: 25840
s = input()
t = input()
n = len(t)
m = len(s)
ans = [n]*(m-n+1)
for i in range(n):
    for j in range(m-n+1):
        if t[i] == s[j+i]:
            ans[j] -= 1
# print(ans)
print(min(ans))

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    LL h;
    cin>>h;
    
    LL total = 0;
    LL num_enemy = 1;
    while(h>0){
        total += num_enemy;
        h /= 2;
        num_enemy *= 2;
    }

    cout<<total<<endl;

    return 0;
}

Measured memory_bytes: 256
''' 
    [Bit]
'''
class Bit:
    """ used for only int(>=0) 
        1-indexed (ignore 0-index)
    """
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.depth = n.bit_length()
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def lower_bound(self, x):
        """ 累積和がx以上になる最小のindexと、その直前までの累積和 """
        sum_ = 0
        pos = 0
        for i in range(self.depth, -1, -1):
            k = pos + (1 << i)
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += 1 << i
        return pos + 1, sum_

    def get_less_than_x_cnt(self, x):
        """ 累積和がx未満 の個数 """
        lb_pos, lb_sum = self.lower_bound(x)
        return lb_pos-1

    def get_less_than_and_x_cnt(self, x):
        """ 累積和がx以下 の個数 """
        lb_pos, lb_sum = self.lower_bound(x+1)
        return lb_pos-1
    
    def get_more_than_x_cnt(self, x):
        """ 累積和がxより大きい 個数 """
        return self.size - self.get_less_than_and_x_cnt(x)


n = int(input())
al = list(map(int, input().split()))
bit = Bit(n)

a_to_i = [0]*(n+1)
for i,a in enumerate(al):
    a_to_i[a] = i+1

ans = 0
for a in range(1,n+1):
    curr_i = a_to_i[a]
    all_left_cnt = bit.sum(curr_i)
    if all_left_cnt == 0:
        left_cnt = curr_i
    else:
        left_i, _ = bit.lower_bound(all_left_cnt)
        left_cnt = curr_i - left_i

    right_i, _ = bit.lower_bound(all_left_cnt+1)
    right_cnt = right_i - curr_i
    all_cnt = right_cnt*left_cnt
    a_sum = a*all_cnt
    ans += a_sum
    bit.add(curr_i,1)

    # print(a,left_cnt,right_cnt)

print(ans)

Measured memory_bytes: 100772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K , A , B;
  int x;
  int y = 0;
  // ここにプログラムを追記
  

    cin >> N >> K;
 for (int i = 0; i < N; i++) {
    cin >> x;
      A = x;
      B = K - x;
     if (A < B) {
       y = y + 2 * A; }
     else {y = y + 2 * B; }
} 
  
  cout << y << endl;

}

Measured memory_bytes: 256
def modComb(n,r,mod):
    nume = 1
    deno = 1
    for i in range(r):
        nume = nume*(n-i) % mod
        deno = deno*(i+1) % mod
    return nume*pow(deno, mod-2, mod) % mod

n, a, b = map(int, input().split())

mod = 10**9+7

ans = (pow(2, n, mod) -1 -modComb(n,a,mod) - modComb(n,b,mod)) % mod

print(ans)

Measured memory_bytes: 9220
fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let m = v[1];
    let mut vv = vec![0usize; n];

    for i in 0..m {
        let vvv = read_vec::<usize>();
        vv[vvv[0] - 1] += 1;
        vv[vvv[1] - 1] += 1;
    }
    for a in vv {
        println!("{}", a);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

const ll INF=100000000001;
int main() {
	int h,w;
	cin>>h>>w;
	char d1[52][52]={};
	string s;
	for(int i=0;i<52;++i){
		for(int j=0;j<52;j++){
			d1[i][j]='.';
		}
	}

	for(int i=1;i<h+1;++i){
		cin>>s;
		for(int j=0;j<w;j++){
			d1[i][j+1]=s[j];
		}
	}
	for(int i=1;i<h+1;++i){
		for(int j=1;j<w+1;j++){
			if(d1[i][j]=='#'){
				cout<<"#";
			}else{
				int k=0;
				if(d1[i-1][j-1]=='#')k++;
				if(d1[i-1][j]=='#')k++;
				if(d1[i-1][j+1]=='#')k++;
				if(d1[i][j-1]=='#')k++;
				if(d1[i][j+1]=='#')k++;
				if(d1[i+1][j-1]=='#')k++;
				if(d1[i+1][j]=='#')k++;
				if(d1[i+1][j+1]=='#')k++;
				cout<<k;
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
    IOS();
    ll n;
    cin >> n;
    for (int i=0;i<n;++i) cin >> d[i];
    sort(d,d+n);

    ll sum = 0;
    int it = -1;
    for (int i=0;i<n-1;++i) {
        sum += d[i];
        if (sum * 2 < d[i+1]) it = i;
    }
    cout << n - it - 1 << endl; 
}


Measured memory_bytes: 4372
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	static Node[] V;
	
	public static void main(String[] args) {
		int Vn = sc.nextInt();
		int En = sc.nextInt();
		int r = sc.nextInt();
		
		V = new Node[Vn]; 
		for(int i=0; i<Vn; i++) {
			V[i] = new Node();
		}
		
		for(int i=0; i<En; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int d = sc.nextInt();
			V[s].nbr.add(new Edge(t, d));
		}
		
		V[r].min = 0;
		
		for(int i=0; i<Vn; i++) {
			boolean flag = false;
			for(int j=0; j<Vn; j++) {
				Node n = V[j];
				for(Edge e : n.nbr) {
					if(n.min != Integer.MAX_VALUE && n.min + e.d < V[e.t].min) {
						V[e.t].min = n.min + e.d;
						flag = true;
					}
				}
			}
			
			if(i == Vn-1 && flag) {
				System.out.println("NEGATIVE CYCLE");
				return;
			}
		}
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<Vn; i++) {
			if(V[i].min == Integer.MAX_VALUE) {
				ans.append("INF");
			} else {
				ans.append(V[i].min);
			}
			ans.append("\n");
		}
		System.out.print(ans);
	}
	
	static class Node {
		int min = Integer.MAX_VALUE;
		Set<Edge> nbr = new HashSet<>();
	}
	
	static class Edge {
		int t;
		int d;
		
		Edge(int t, int d) {
			this.t = t;
			this.d = d;
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 59620
#include <iostream>
#include <string>

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

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(N==(i*j)){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);

	ll n, m, s = 0, ans = 0;
	cin >> n >> m;
	map<ll, ll> mp;
	mp[0]++;
	rep(i, n) {
		ll x;
		cin >> x;
		s += x;
		ans += mp[s%m];
		mp[s%m]++;
	}
	cout << ans << endl;
	return 0;
}

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

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int INF = 1e9;

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
//    freopen("out.txt", "w", stdout);
    
    string s;
    cin >> s;
    if(s[s.length()-1] == 's') s += "es";
    else s+="s";
    cout << s;

    return 0;

}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;

    if(k == 0) {
        out(n*n);
    }
    else {
        ll ans = 0;
        exrep(b, k+1, n) {
            ll x = (n+1-b)/b;
            ll y = (n+1-b)%b;
            ans += (b-k)*(x+1) + max(0LL, y-k);
        }
        out(ans);
    }

    re0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=1e9;
int dp[12525];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int h, n, a[12525], b[12525];
  cin>>h>>n;
  double c[12525], d[12525];
  REP(i, n){
    cin>>a[i]>>b[i];
    c[i]=a[i];
    d[i]=b[i];
  }
  // vi ord(n);
  // iota(ALL(ord), 0);
  // sort(ALL(ord), [&c, &d](int x, int y){
  //   if(c[x]/d[x]==c[y]/d[y]){
  //     return d[x]<d[y];
  //   }
  //   return c[x]/d[x]<c[y]/d[y];
  // });
  REP(i, h+1){
    dp[i]=INF;
  }
  dp[0]=0;
  REP(i, h+1){
    if(dp[i]==INF){
      continue;
    }
    REP(j, n){
      if(i+a[j]>=h){
        CHMIN(dp[h], dp[i]+b[j]);
      }
      else{
        CHMIN(dp[i+a[j]], dp[i]+b[j]);
      }
    }
  }
  cout<<dp[h]<<'\n';
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int n, i;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		if((x2-x1==0&&x4-x3==0) || ((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3))) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n;
  cin >> n;
  cout << "ABC" << n;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int INF = 1e+9+7;

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<int,vector<int>,greater<int>> X,D;
    int tmp;
    rep(i,M){
        cin >> tmp;
        X.push(tmp);
    }
    int before=X.top();
    int cur;
    X.pop();

    int ans=0;
    if(N<M){
        while(!X.empty()){
            cur=X.top();
            X.pop();
            D.push(abs(cur-before));
            before=cur;
        }
        rep(i,M-N){
            ans+=D.top();
            D.pop();
        }
    }




    cout << ans << endl;
        
}

Measured memory_bytes: 1400
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B=LI()
    ans = 0
    for i,b in enumerate(B):
        if A[i]<=b:
            ans += A[i]
            b -= A[i]
            ans += max(0,min(A[i+1],b))
            A[i+1] = max(0,A[i+1]-b)
        else:            
            ans += b
            b = 0
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 98912