akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

class Solver {
  private ArrayList<Integer> b;
  private ArrayList<Integer> operations;
  
  private boolean dfs() {
    if (b.size() == 0) {
      return true;
    }
    for (int i = b.size() - 1; i >= 0; i--) {
      if (b.get(i) > i+1) {
        return false;
      } else if (b.get(i) == i+1) {
        b.remove(i);
        if (dfs()) {
          operations.add(i + 1);
          return true;
        } else {
          return false;
        }
      }
    }
    return false;
  }
  
  public List<Integer> solve(ArrayList<Integer> b) {
    this.b = b;
    this.operations = new ArrayList<>();
    if (dfs()) {
      return this.operations;
    } else {
      return Arrays.asList(-1);
    }
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    ArrayList<Integer> b = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      b.add(reader.nextInt());
    }
    List<Integer> solution = new Solver().solve(b);
    for (int num : solution) {
      out.println(num);
    }
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



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

int main() {
  int sx, sy;
  while(cin >> sx >> sy, sx+sy) {
    int x = 1, y = 1;
    int dx = 0, dy = 1;
    while(1) {
      string a;
      cin >> a;
      int n;
      if (a == "FORWARD") {
        cin >> n;
        x += dx * n;
        y += dy * n;
        x = min(sx, x);
        x = max(1, x);
        y = min(sy, y);
        y = max(1, y);
      } else if (a == "BACKWARD") {
        cin >> n;
        x -= dx * n;
        y -= dy * n;
        x = min(sx, x);
        x = max(1, x);
        y = min(sy, y);
        y = max(1, y);
      } else if (a == "RIGHT") {
        if (dx==1&&dy==0) {
          dx = 0; dy = -1;
        } else if (dx==0&&dy==1) {
          dx = 1; dy = 0;
        } else if (dx==0&&dy==-1) {
          dx = -1; dy = 0;
        } else if (dx==-1&&dy==0) {
          dx = 0; dy = 1;
        }
      } else if (a == "LEFT") {
        if (dx==1&&dy==0) {
          dx = 0; dy = 1;
        } else if (dx==0&&dy==1) {
          dx = -1; dy = 0;
        } else if (dx==0&&dy==-1) {
          dx = 1; dy = 0;
        } else if (dx==-1&&dy==0) {
          dx = 0; dy = -1;
        }
      } else if (a == "STOP") {
        break;
      }
    }
    cout << x << " " << y << endl;
  }
}

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

int main(){
  int N , D ;
  cin >> N >> D;
  vector<vector<int>> x(N, vector<int>(D));
  for(int i = 0; i < N; i++)
    for(int j = 0; j < D; j++)
      cin >> x[i][j]; 
  int ans = 0;
  for(int i = 0; i < N; i++){
    for(int k = i + 1; k < N; k++){
      int dist2 = 0;
      for(int j = 0; j < D; j++) dist2 += (x[i][j] - x[k][j]) * (x[i][j] - x[k][j]);
      int dist1 = sqrt(dist2); 
      if(dist2 == dist1 * dist1) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    long n;
    long k;
    long c=0;
    cin>>n>>k;
    if(n<=k){
        cout<<0;
    }else{
        long h[n];
        for(long i=0;i<n;i++){
            cin>>h[i];
        }
        sort(h,h+n);
        for(long i=0;i<n-k;i++){
            c+=h[i];
        }
        cout<<c;
    }
    
}



Measured memory_bytes: 1920
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N;
    cin >> N;

    vector<long long> num(N + 1, 1LL);
    num[0] = 0;
    num[1] = 1;
    for (long long i = 2; i <= N; ++i) {
        for (long long n = 1; n * i <= N; ++n) {
            num[n * i] += 1;
        }
    }
    long long ans = 0LL;
    for (long long i = 0; i < num.size(); ++i) {
        ans += i * num[i];
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  vector<int> vec;
  int N, ret = -1;
  cin >> N;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    vec.push_back(a);
  }
  int i = N;
  while(i == N){
  	for(i = 0; i < N; i++){
      if(vec[i] % 2 != 0) break;
      vec[i] /= 2;
  	}
    ret++;
  }
  cout << ret << endl;
}


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

int main(void) {
  std::map<char, char> table = {
    {'A', 'T'},
    {'T', 'A'},
    {'C', 'G'},
    {'G', 'C'}
  };

  char c;
  std::cin >> c;
  std::cout << table[c] << std::endl;

  return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod = 2019
    for i in range(L, R+1):
        for j in range(i + 1, R+1):
            m = i * j % 2019
            if m < mod:
                mod = m
    print(mod)

Measured memory_bytes: 3060
S=input()
N=len(S)

ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

if S[0]!="A":
    print("WA")
    exit()

c=0
idx=0
for i in range(2,N-1):
    if S[i]=="C":
        c+=1
        idx=i

if c!=1:
    print("WA")
    exit()

for i in range(1,N):
    if not i ==idx:
        if S[i] in ABC:
            print("WA")
            exit()

print("AC")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
  
    int N;cin>>N;
    string S;cin>>S;
    vector<int> T(2*N);
    bool ok=true;
    int leftcnt=0,cnt=0;
    for(int i=0;i<2*N;i++){
        if(leftcnt%2==0){
            if(S[i]=='B'){
                leftcnt++;
                cnt++;
            }else{
                leftcnt--;
                T[i]=1;
            }
        }else{
            if(S[i]=='B'){
                leftcnt--;
                T[i]=1;
            }else{
                leftcnt++;
                cnt++;
            }
        }
        //if(leftcnt<0) ok=false;
    }
    
    if(cnt==N){
        ll ans=1;
        ll rightcnt=0;
        for(int i=2*N-1;i>=0;i--){
            if(T[i]) rightcnt++;
            else{
                if(rightcnt<=0) ok=false;
                ans*=rightcnt;
                ans=ans%mod;
                rightcnt--;
            }
        }
        for(ll i=1;i<=N;i++){
            ans=ans*i;
            ans=ans%mod;
        }
        if(!ok) ans=0;
        cout<<ans<<endl;
    }else cout<<0<<endl;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


ll cal(ll s){
	if(s==0) return 0;
	ll q1=(s)/4, q2=s%4;
	if(q2==1) return 1;
	if(q2==3) return 0;
	return q1 * 4 + (q2==2? 3:0);

}


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

	ll a,b;
	cin >>a >>b;
	
	ll r= cal(a-1), t=cal(b);
	t ^=r;
	
	cout <<  t <<"\n";
	
/*
	int s=0;
	rep2(i,0, 101){
		s ^=i;
		printf("%3d %4d %4d: ",i, s, cal(i));
		if(i%4==3) printf("\n");
	}
*/
	return 0;
}




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

int main() {
    int n;
    cin >> n;
    int c0 = 0;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    for (int i = 0; i < n; i++) {
        string c;
        cin >> c;
        if (c == "AC") {
            c0++;
        }
        else if (c == "WA") {
            c1++;
        }
        else if (c == "TLE") {
            c2++;
        }
        else {
            c3++;
        }
    }
    cout << "AC x " + to_string(c0) << endl;
    cout << "WA x " + to_string(c1) << endl;
    cout << "TLE x " + to_string(c2) << endl;
    cout << "RE x " + to_string(c3) << endl;
    return 0;
}

Measured memory_bytes: 3692
<?php
  const DIRS = "RDLU";
  $p = array(1,0,0);
  $path = array('R');
  $stepx =  array(1,0,-1,0);
  $stepy = array(0,1,0,-1);

  function frontIsClear($x,$y,$d,$l) {
      return ($d == 0 && ($y>0 ? !$l[2*$y-1][$x] : 1)) || ($d == 1 && ($x<4 ? !$l[2*$y][$x] : 1))
          || ($d == 2 && ($y<4 ? !$l[2*$y+1][$x] : 1)) || ($d == 3 && ($x>0 ? !$l[2*$y][$x-1] : 1));
  }

  function canMove($x,$y,$d,$l) {
      return ($d==0 && $x!=4 && $l[2*$y][$x]) || ($d==1 && $y!=4 && $l[2*$y+1][$x])
          || ($d==2 && $x!=0 && $l[2*$y][$x-1]) || ($d==3 && $y!=0 && $l[2*$y-1][$x]);
  }

  function move(&$p,$stepx,$stepy) {
      if($p[2] == 0 || $p[2] == 2)
          $p[0] = $p[0] + $stepx[$p[2]];
      else
          $p[1] = $p[1] + $stepy[$p[2]];
  }

  for($i=0;$i<9;$i++)
      $l[] = trim(fgets(STDIN));

  while(true) {
       if(!frontIsClear($p[0],$p[1],$p[2],$l)){
          $p[2] = ($p[2]+3) % 4;
       } else {
           while(!canMove($p[0],$p[1],$p[2],$l))
              $p[2] = ($p[2]+1) % 4;
       }
       if($p == array(0,0,0))
           break;
       move($p,$stepx,$stepy);
       $path[] = DIRS[$p[2]];
  }

  echo implode('',$path).PHP_EOL;

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

int main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    long long s1=0,s2=0,r1=0,r2=0,ans;
    for(int i=0;i<n;i++){
        s1+=a[i];
        if((i&1)&&s1<=0){
            r1=r1+1-s1;
            s1=1;
        }else if(!(i&1)&&s1>=0){
            r1=r1+s1+1;
            s1=-1;
        }

        s2+=a[i];
        if(!(i&1)&&s2<=0){
            r2=r2+1-s2;
            s2=1;
        }else if((i&1)&&s2>=0){
            r2=r2+s2+1;
            s2=-1;
        }
    }
    ans=min(r1,r2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int K, N;
    cin >> K >> N;
    int s = -1;
    int A[N + 1];
    rep(i, N) cin >> A[i];
    A[N] = K + A[0];
    rep(i, N) {
        s = max(s, A[i + 1] - A[i]);
    }
    cout << K - s << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);){
			double r = sc.nextDouble();
			
			System.out.format("%.6f %.6f\n", r * r * Math.PI, 2 * Math.PI * r);
		}
	}
}



Measured memory_bytes: 28320
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    double x;
    cin >> N >> K;
    vector<double> p(N);
    for (int i = 0; i < N; i++) {
        cin >> x;
        p[i] = (x + 1) / 2 ;
    }
    vector<double> sum(N+1);
    sum[0] = 0;
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + p[i];
    double ans = 0;
    for (int i = K; i <= N; i++) {
        ans = max(ans, sum[i] - sum[i-K]);
    }
    cout << fixed << setprecision(10) << ans << '\n';
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 2005 ;
using namespace std ;

int n, m, a[N][N], b[N][N], st[N], ans, l[N], r[N] ; 
char s[N][N] ;

int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, n) scanf("%s", s[i] + 1) ;
	ans = max(n, m), -- n, -- m ;
	rep(i, 1, n) rep(j, 1, m) a[i][j] = ((s[i][j] == '#') ^ (s[i + 1][j] == '#') ^ (s[i][j + 1] == '#') ^ (s[i + 1][j + 1] == '#')) ;
	rep(i, 1, n) rep(j, 1, m) b[i][j] = (a[i][j] ? 0 : b[i - 1][j] + 1) ;
	rep(i, 1, n) {
		int top = 0 ;
		rep(j, 1, m) {
			for ( ; top && b[i][st[top]] >= b[i][j] ; -- top) ;
			l[j] = top ? st[top] + 1 : 1, st[++ top] = j ;
		}
		top = 0 ;
		for (int j = m ; j; -- j) {
			for ( ; top && b[i][st[top]] >= b[i][j] ; -- top) ;
			r[j] = top ? st[top] - 1 : m, st[++ top] = j ;
		}
		rep(j, 1, m) ans = max(ans, (r[j] - l[j] + 2) * (b[i][j] + 1)) ;
	}
	printf("%d\n", ans) ;
	return 0 ; 
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[500][500], size[500][500], INF = 1LL << 60;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < 500; ++i)
		for (int j = 0; j < 500; ++j)
			dp[i][j] = INF;
	for (int i = 0; i < n; ++i) {
		cin >> size[i][i];
		dp[i][i] = 0;
	}
	for (int k = 1; k < n; ++k)
		for (int i = 0; i < n; ++i) {
			int bound = min(i + k, n);
			for (int j = i; j < bound; ++j) {
				if (dp[i][j] + dp[j + 1][i + k] + size[i][j] + size[j + 1][i + k] < dp[i][i + k]) {
					dp[i][i + k] = dp[i][j] + dp[j + 1][i + k] + size[i][j] + size[j + 1][i + k];
					size[i][i + k] = size[i][j] + size[j + 1][i + k];
				}
			}
		}
	cout << dp[0][n - 1] << '\n';
	return 0;
}

Measured memory_bytes: 3968
mod = 10**9+7
N,X,Y,Z = map(int, input().split())
Num = 1<<(X+Y+Z-1)
ng = ((((1<<X)+1)<<Y)+1)<<(Z-1)

dp = [[0]*Num for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for k in range(Num):
        for j in range(1,11):
            a = (k<<j)|(1<<(j-1))
            if a&ng != ng:
                a &= Num-1
                dp[i+1][a] += dp[i][k]
                dp[i+1][a] %= mod
cnt = 1
for i in range(N):
    cnt *= 10
    cnt %= mod
for x in dp[N]:
    cnt -= x
    cnt %= mod
print(cnt)

Measured memory_bytes: 63068
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        String s= sc.next();
        if(length % 2 != 0){
            System.out.println("No");
        } else{
            String a = s.substring(0, length / 2);
            String b = s.substring(length / 2, length);
            System.out.println(a.equals(b) ? "Yes" : "No")  ;
        }
        sc.close();
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<stdio.h>



using namespace std;


int main(void)
{
	int a;
	double ans = 0;
	int b;

	cin >> a;
	if (a % 2 == 0)
	{
		cout << 0.5 << endl;
	}
	else
	{
		b = a / 2;
		ans = b/(double)a;
		cout << 1-ans << endl;
	}
	return 0;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		// Listに標準入力の値を取得
		ArrayDeque<String> inputs = new ArrayDeque<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			while (br.ready()) {
				String[] lineArray = br.readLine().split(" ");
				Arrays.<String> stream(lineArray).forEach(s -> inputs.add(s.trim()));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		// 入力取得
		inputs.removeFirst();

		// Set
		Set<String> sets = new HashSet<>();

		for (String product : inputs) {
			sets.add(product);
		}

		System.out.println(sets.size());
	}
}


Measured memory_bytes: 73748
#include <cstdio>
#include <cmath>
#include <cstring>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <functional>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int main() {
	int d,c;
	scanf("%d %d",&d,&c);
	printf("%d\n",d*c);
}

Measured memory_bytes: 1188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  if(a+b%2==0) cout << (a+b)/2 << endl;
  else cout << (a+b+1)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Text.Printf

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

main :: IO ()
main = do
    [h, w] <- getInts
    [a, b] <- getInts
    print $ (h - a) * (w - b)


Measured memory_bytes: 508
#include <iostream>

#define max 10000
using namespace std;


int main() {
    int sem = 0, i = 1;
    char x, y, ch;
    cin >> x >> y;
    while(cin >> ch && sem == 0) {
        if (ch == x) {
            cout << i << " " << i+2;
            sem = 1;
        } else if (ch == y) {
            cout << i+1 << " " << i+2;
            sem = 1;
        } else {
            x = y;
            y = ch;
        }
        i++;
    }
    if(i==1 && x == y) cout << "1 2";
    else if(sem == 0) cout << "-1 -1";
    return 0;
}


Measured memory_bytes: 256
from collections import *
n=input()
a=Counter(map(int,raw_input().split()))
s=1
if n&1:
    if 0 not in a or a[0]>1:
        print 0
        exit(0)
    s+=1
while s<n:
    if s not in a or a[s]!=2:
        print 0
        exit(0)
    s+=2
print pow(2,n/2,10**9+7)

Measured memory_bytes: 11444
/**
 *    author:  tourist
 *    created: 06.07.2020 09:34:43       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  cin >> x >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    s.insert(y);
  }
  for (int d = 0; ; d++) {
    if (s.find(x - d) == s.end()) {
      cout << x - d << '\n';
      break;
    }
    if (s.find(x + d) == s.end()) {
      cout << x + d << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int l[101];
void f(x){
  if(x<101){
  l[x]=1;
  f(x+4);
  f(x+7);
  }
}
int main(){
  int N;
  scanf("%d",&N);

  int i;
  for (i = 1; i < 101; i++) {
    l[i]=0;
  }
  f(0);
  if(l[N]==1) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

const int M = 13;

string s;
ll t = 1, ans;
ll dp[2][13];
int ind[13][13];
int ho = 0, ge = 1;

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

    rep(i,M) {
        rep(j,M) ind[i][j] = i*j%M;
    }

    cin >> s;
    dp[ho][0] = 1;
    for (int i = (int)s.size()-1; i >= 0; i--) {
        if (s[i] != '?') {
            int x = t*(s[i]-'0')%M;
            rep(j,M) {
                if (x == M) x -= M;
                dp[ge][x++] = dp[ho][j];
            }
        } else {
            ll sum = 0;
            rep(j,9) sum += dp[ho][ind[t][j]];
            for (int j = 9; j < M; j++) {
                sum += dp[ho][ind[t][j]];
                dp[ge][ind[t][j]] = sum;
                sum = sum+10*MOD-dp[ho][ind[t][j-9]];
            }
            for (int j = 0; j < 9; j++) {
                sum += dp[ho][ind[t][j]];
                dp[ge][ind[t][j]] = sum;
                sum = sum+10*MOD-dp[ho][ind[t][j+4]];
            }
        }
        if (i%2) rep(j,M) dp[ge][j] %= MOD;
        t = t * 10 % M;
        swap(ho,ge);
    }
    cout << dp[ho][5]%MOD << endl;
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int n; 
ll apply(vector<ll> &arr){
    vector<ll> tmp(n);
    for (int i = 0; i < n; i++){
        tmp[i] = arr[i] / n;
        arr[i] %= n;
    }
    ll tot = accumulate(tmp.begin(), tmp.end(), 0LL);
    for (int i = 0; i < n; i++){
        arr[i] += (tot - tmp[i]);
    }
    return tot;
}

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

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

    ll res = 0;
    ll cur = 0;
    while ((cur = apply(arr))){
        res += cur;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<iomanip>

using namespace std;

int box[6] = {};
int a;

class Dice {
public:
	void s();
	void w();
	void n();
	void e();
};


void Dice::s() {
	a = box[0];
	box[0] = box[4];
	box[4] = box[5];
	box[5] = box[1];
	box[1] = a;
}
void Dice::w() {
	a = box[0];
	box[0] = box[2];
	box[2] = box[5];
	box[5] = box[3];
	box[3] = a;
}
void Dice::n() {
	a = box[0];
	box[0] = box[1];
	box[1] = box[5];
	box[5] = box[4];
	box[4] = a;
}
void Dice::e() {
	a = box[0];
	box[0] = box[3];
	box[3] = box[5];
	box[5] = box[2];
	box[2] = a;
}

int main() {
	int i;
	string str1,str2;
	Dice dice1;
	for (i = 0; i < 6; i++) {
		cin >> box[i];
	}
	getline(cin, str1);
	getline(cin, str2);

	for (i = 0;i<str2.length();i++) {
		if (str2[i] == 'S') {
			dice1.s();
		}
		else if (str2[i] == 'W') {
			dice1.w();
		}
		else if (str2[i] == 'N') {
			dice1.n();
		}
		else {
			dice1.e();
		}
	}
	std::cout << box[0] << endl;

	return 0;
}



Measured memory_bytes: 3148
N, M = input().split()
N = int(N)
M = int(M)
PY = []
for i in range(M):
    P, Y = input().split()
    PY.append((P, Y, i))

sortedPY = sorted(PY, key=lambda x:int(x[1]))

Pwas = [0 for i in range(N)]
for i,x in enumerate(sortedPY):
    P = x[0]
    idx = int(P) - 1
    Pwas[idx] = Pwas[idx] + 1
    PY[x[2]] = P.zfill(6) + str(Pwas[idx]).zfill(6)

for x in PY:
    print(x)

Measured memory_bytes: 35940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

pll dp[(1LL<<18)+5][20];

ll res[4];
pll change(pll l,pll r){
    res[0]=l.first;
    res[1]=l.second;
    res[2]=r.first;
    res[3]=r.second;
    sort(res,res+4);
    return pll(res[3],res[2]);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(1<<n);
    rep(i,1<<n) scanf("%lld",&a[i]);
    rep(i,1<<n){
        dp[i][0].first = a[i];
        dp[i][0].second = -1;
    }
    rep(i,1<<n){
        for(int j=1;j<=n;j++){
            if(i>>(j-1)&1){
                dp[i][j] = change(dp[i][j-1],dp[i^(1<<(j-1))][j-1]);
            }else{
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    ll ans = 0;
    for(int i=1;i<(1<<n);i++){
        ans = max(ans,dp[i][n].first+dp[i][n].second);
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 87372
/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

const int N = 2e5 + 5;

void solve() {
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll mv = min(k, x / d);
    k -= mv;
    x -= mv * d;
    if(k % 2 == 0) cout << x << '\n';
    else cout << d - x << '\n';
    return;
}

int main() {

    solve();
    return 0;
}


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

int N, K, R, S, P;
string T;
int dp[100010][3];

int calc(int s) {
    int now = s;
    int i = 0;
    while (now<N) {
        dp[i+1][0] = max(dp[i][1], dp[i][2])+(T[now]=='s' ? R:0);
        dp[i+1][1] = max(dp[i][0], dp[i][2])+(T[now]=='p' ? S:0);
        dp[i+1][2] = max(dp[i][0], dp[i][1])+(T[now]=='r' ? P:0);
        //cout << now << " " << T[now] << endl;
        //cout << dp[i+1][0] << " " << dp[i+1][1] << " " << dp[i+1][2] << endl;
        now += K;
        i++;
    }
    return max({dp[i][0], dp[i][1], dp[i][2]});
}
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K >> R >> S >> P;
    cin >> T;
    int ans = 0;
    rep(i, K) {
        ans += calc(i);
        //cout << calc(i) << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2768
#include<stdio.h>
struct Card {
	char suit;
	int value;
};

void swap(struct Card C[], int a, int b)
{
	struct Card tmp;
	tmp = C[a];
	C[a] = C[b];
	C[b] = tmp;

	return;
}

void bubbleSort(struct Card C[], int N)
{
	int i, j;
	for(i = 0; i < N; ++i) {
		for(j = N - 1; j > i; --j) {
			if(C[j].value < C[j-1].value)
				swap(C, j, j-1);
		}
	}
	return;
}

void selectionSort(struct Card C[], int N)
{
	int i, j;
	for(i = 0; i < N; ++i) {
		int minj = i;
		for(j = i; j < N; ++j) {
			if(C[j].value < C[minj].value)
				minj = j;
		}
		swap(C, i, minj);
	}
}

void showResult(struct Card C[], int N)
{
	int i;
	for(i = 0; i < N; ++i) {
		if(i == N-1)
			printf("%c%d\n", C[i].suit, C[i].value);
		else
			printf("%c%d ", C[i].suit, C[i].value);
	}
}

int isStable(struct Card C1[], struct Card C2[], int N)
{
	int i;
	for(i = 0; i < N; ++i) {
		if(C1[i].suit != C2[i].suit)
			return 0;
	}

	return 1;
}

int main()
{
	int i;
	int N;
	scanf("%d\n", &N);

	struct Card C1[N], C2[N];
	for(i = 0; i < N; ++i) {
		scanf(" %c%d", &C1[i].suit, &C1[i].value);
		C2[i].suit = C1[i].suit;
		C2[i].value = C1[i].value;
	}
	bubbleSort(C1, N);
	showResult(C1, N);
	if(isStable(C1, C1, N))
		printf("%s\n", "Stable");
	else
		printf("%s\n", "Not stable");
	selectionSort(C2, N);
	showResult(C2, N);
	if(isStable(C1, C2, N))
		printf("%s\n", "Stable");
	else
		printf("%s\n", "Not stable");
    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


    string s; cin >>s;

    if(s == "RRR") cout <<3 <<endl;
    else if(s == "RRS" || s == "SRR") cout <<2 <<endl;
    else if(s == "RSR" || s == "RSS" || s == "SRS" || s == "SSR") cout <<1 <<endl;
    else cout <<0 <<endl;

    return 0;
}


Measured memory_bytes: 3564
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC124 {
  class ProblemC {
    static void Main(string[] args) {
      string s = Input.str;
      int ans1 = 0, ans2 = 0;
      // |S| = 偶数のとき
      if (s.Length % 2 == 0) {
        char c = s[0];
        // 偶数番目
        for (int i = 0; i < s.Length / 2; i++) {
          if (s[2 * i] != c) {
            ans1++;
          } else {
            ans2++;
          }
        }
        // 奇数番目
        for (int i = 0; i < s.Length / 2; i++) {
          if (s[2 * i + 1] == c) {
            ans1++;
          } else {
            ans2++;
          }
        }
      } else {
        char c = s[0];
        // 偶数番目
        for (int i = 0; i < s.Length / 2 + 1; i++) {
          if (s[2 * i] != c) {
            ans1++;
          } else {
            ans2++;
          }
        }
        // 奇数番目
        for (int i = 0; i < s.Length / 2; i++) {
          if (s[2 * i + 1] == c) {
            ans1++;
          } else {
            ans2++;
          }
        }
      }
      System.Console.WriteLine(Math.Min(ans1, ans2));
      
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}


Measured memory_bytes: 13116
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int n = Integer.parseInt(st.nextToken());
      long m = Long.parseLong(st.nextToken());
      
      int[] array = new int[n+1];
      st = new StringTokenizer(f.readLine());
      for(int k = 1; k <= n; k++){
         array[k] = Integer.parseInt(st.nextToken());
      }
      
      //find cycle
      ArrayList<Integer> cycle = new ArrayList<Integer>();
      int[] lastindex = new int[n+1];
      Arrays.fill(lastindex,-1);
      
      int index = 1;
      int time = 0;
      
      while(lastindex[index] == -1){
         if((long)time == m){
            out.println(index);
            out.close();
            return;
         }
         cycle.add(index);
         lastindex[index] = time;
         index = array[index];
         time++;
      }
      
      long mod = (long)(time-lastindex[index]);
      int answerindex = (int)((m-(long)lastindex[index]+mod)%mod) + lastindex[index];
      out.println(cycle.get(answerindex));
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 55588
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
const int INF=1000000007;

int main (void){
    int a,b,c,d,e,x,y,m,n,i,j,k,l,p,q;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    if(d==24) cout << "Christmas Eve" << endl;
    if(d==23) cout << "Christmas Eve Eve" << endl;
    if(d==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

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

using namespace std;

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

	int a_max = *max_element(a.begin(), a.end());
	vector<int> b(a_max + 1, 0);
	for (int i = 0; i < n; i++)
	{
		if (b[a[i]] != 0)
		{
			if (b[a[i]] == -1)
				b[a[i]] = 1;
			continue;
		}
		b[a[i]] = -1;
		for (int k = a[i] * 2; k <= a_max; k += a[i])
			b[k] = 1;
	}

	int count = 0;
	for (int i = 0; i < n; i++)
	{
		if (b[a[i]] == -1)
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 8032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    

    int m;
    cin >> m;
    cout << 48 - m << endl;
}


Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  int ret = n / 500 * 1000;
  ret += (n % 500) / 5 * 5;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	In := readLineInt()
	X, A, B := In[0], In[1], In[2]

	switch {
	case B-A <= 0:
		fmt.Println("delicious")
	case B-A <= X:
		fmt.Println("safe")
	default:
		fmt.Println("dangerous")
	}
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a, b, c;
	cin >> a >> b >> c;
	if(c <= a+b){
		print("No")
	}
	else{
		if(4*a*b < (c-a-b)*(c-a-b)){
			print("Yes")
		}
		else{
			print("No")
		}
	}
	return 0;
}

Measured memory_bytes: 256
A,B,H,M = gets.split.map(&:to_i)
tha = (60 * H + M).to_f / 720
thb = M.to_f / 60
puts Math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * Math.cos(Math::PI * 2 * (tha - thb))))


Measured memory_bytes: 14716
#include <stdio.h>

int main(void) {
  int t, n, i;
  int tic[4] = {6000, 4000, 3000, 2000};

  for (i = 0; i < 4; i++) {
    scanf("%d %d", &t, &n);
    printf("%d\n", tic[t-1] * n);
  }

  return 0;
}

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

int main() {
    int A,B,C;
    int ans = 0;
    cin >> A >> B >> C;
    int A_i = A;
    int B_i = B;
    int C_i = C;
    while (true) {
        if (A % 2 != 0 or B % 2 != 0 or C % 2 != 0) {
            cout << ans << endl;
            break;
        }
        int a = A/2;
        int b = B/2;
        int c = C/2;
        A = b+c;
        B = a+c;
        C = a+b;
        ans++;
        if (A == A_i and B == B_i and C == C_i) {
            cout << -1 << endl;
            break;
        }
    }
}

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

int main(){
  string number;
  int sum;

  while (cin >> number, number != "0")
    {
      sum = 0;
      for (size_t i = 0; i < number.size(); ++i)
        {
          sum += number[i] - '0';
        }
      cout << sum << endl;
    }
}

Measured memory_bytes: 1188
import math

n = int(input())
ta = [[int(i) for i in input().split()] for j in range(n)]

a = 1
b = 1
for i in range(n):
    #n = max(math.floor(a/ta[i][0]), math.floor(b/ta[i][1]))
    n = max(~-a//ta[i][0] + 1, ~-b//ta[i][1] + 1)
    a = n * ta[i][0]
    b = n * ta[i][1]

print(a+b)

Measured memory_bytes: 3188
N, K = map(int, input().split())
s = input()
li = [(0, 0)]
i = 0
while i < N:
    if s[i] == '1':
        l = i
    while i < N and s[i] == '1':
        i += 1
        if not (i < N and s[i] == '1'):
            break
    else:
        i += 1
        continue
    r = i - 1
    li.append((l, r))
    i += 1
li.append((N - 1, N - 1))
ans = 0
if K > len(li):
    K = len(li) - 1
for i in range(len(li) - K):
    ans = max(ans, li[i + K][1] - li[i][0])
print(ans + 1)

Measured memory_bytes: 9976
n = int(input())
hs = list(map(int, input().split(" ")))

ans = True
m = -1
for i in range(0, n):
    if hs[i] > m:
        m = hs[i]
    elif m - hs[i] > 1:
        ans = False
        break
print("Yes" if ans else "No")


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

queue<pair<int,long>> q;

void wfs(vector<vector<int>> &Ed,vector<pair<long,int>> &Ve){
  if(q.empty()==0){
    pair<int,long> v=q.front();
    q.pop();
    Ve[v.first].first+=v.second;
    for(int i=0; i<Ed[v.first].size(); i++){
      if(Ed[v.first][i]!=Ve[v.first].second){
        Ve[Ed[v.first][i]].second=v.first;
        q.push(make_pair(Ed[v.first][i],Ve[v.first].first));
      }
    }
    wfs(Ed,Ve);
  }
}

int main(){
  int N,Q;
  cin >> N >> Q;
  vector<vector<int>> Ed(N);
  for(int i=0; i<N-1; i++){
    int a,b;
  	cin >> a >> b;
    Ed[a-1].push_back(b-1);
    Ed[b-1].push_back(a-1);
  }
  vector<pair<long,int>> Ve(N,make_pair(0,0));
  for(int i=0; i<Q; i++){
    int p,x;
    cin >> p >> x;
    Ve[p-1].first+=x;
  }
  
  q.push(make_pair(0,0));
  wfs(Ed,Ve);
  for(int i=0; i<N; i++){
    cout << Ve[i].first;
    if(i==N-1) cout << endl;
    else cout << ' ';
  }
}

Measured memory_bytes: 35956
#include <stdio.h>

int main(void)
{
	float hei;
	
	while (scanf("%f", &hei) != EOF){
		if (hei > 91.00){
			printf("heavy\n");
		}
		else if (hei > 81.00){
			printf("light heavy\n");
		}
		else if (hei > 75.00){
			printf("middle\n");
		}
		else if (hei > 69.00){
			printf("light middle\n");
		}
		else if (hei > 64.00){
			printf("welter\n");
		}
		else if (hei > 60.00){
			printf("light welter\n");
		}
		else if (hei > 57.00){
			printf("light\n");
		}
		else if (hei > 54.00){
			printf("feather\n");
		}
		else if (hei > 51.00){
			printf("bantam\n");
		}
		else if (hei > 48.00){
			printf("fly\n");
		}
		else if (48.00 >= hei){
			printf("light fly\n");
		}
	}
	
	return (0);
}

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

typedef long long ll;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int yescount,nocount;
  if(a%d==0) nocount=a/d;
  else nocount=a/d+1;
  if(c%b==0) yescount=c/b;
  else yescount = c/b+1;
  if(yescount <= nocount ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
// dp[x][y] = xth position and y candies, no. of ways
// dp[x][0] = 1

// dp[first][0] = dp[first][1] = ..... dp[first][a[0]] = 1

// dp[x][y] = dp[x-1][y] + dp[x-1][y-1] + dp[x-1][y-2] + ...
 				// ..... + dp[x-1][y-a[x]]
// dp[x-1] -> prefix_sum
// dp[x][y] = prefix_sum[y] - prefix_sum[y-a[x]-1]

// dp[last][k]
#include "bits/stdc++.h"
using namespace std;

const int M = 1e9 + 7;

int dp[100][100005];
int a[100];

int main(){
	int n,k;
	cin>>n>>k;
	for(int i = 0;i < n; i++){
		cin>>a[i];
	}
	
	for(int i = 0; i <= a[0]; i++){
		dp[0][i] = 1;
	}
	
	for(int i = 1; i < n; i++){
		// dp[i]
		vector<int> prefix_sum(k+1);
		prefix_sum[0] = dp[i-1][0];
		for(int j = 1; j < k+1; j++){
			prefix_sum[j] = (prefix_sum[j-1] + dp[i-1][j]) % M;
		}
		for(int j = 0; j < k+1; j++){
			// dp[i][j]
			if(j > a[i])
				dp[i][j] = (prefix_sum[j] + M - prefix_sum[j-a[i]-1]) % M;
			else
				dp[i][j] = prefix_sum[j];
		}
		
	}
	cout << dp[n-1][k];
}


Measured memory_bytes: 43048
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

 
struct LazySegmentTree {
private:
    int n;
    vector<LL> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<LL> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, LL x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
 
    LL find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return -1;
        if(a <= l && r <= b) return node[k];
        LL vl = find(a, b, 2*k+1, l, (l+r)/2);
        LL vr = find(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


int main(){
    int N;cin >> N;
    vector<LL> h(N),a(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    LazySegmentTree seg( vector<LL> (N+1,0) );
    for (int i = 0; i < N; i++) {
        seg.update(h[i],h[i]+1,seg.find(0,h[i])+a[i]);        
    }
    cout << seg.find(0,N+1) << endl;
    return 0;
}



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

bool	solve(vector<int> &A, int &n, int i, int m)
{
	int	res;

	if (m == 0)
		return (1);
	if (i == n)
		return (0);
	res = solve(A, n, i + 1, m) || solve(A, n, i + 1, m - A.at(i));
	return (res);
}

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

	int			n;
	int			q;
	cin >> n;
	vector<int>	A(n);

	rep(i, n)
		cin >> A.at(i);
	cin >> q;
	rep(i, q)
	{
		int	m;

		cin >> m;
		if (solve(A, n, 0, m))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}



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

using namespace std;

const int inf = 1e9;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	vector<int> tll(N, inf), tlr(N, inf);
	if (a[0] != 0) tll[0] = 0;
	if (a[N-1] != 0) tlr[N-1] = 0;
	for (int i = 1; i < N; ++i) {
		tll[i] = max(0, tll[i-1]-1);
		if (a[i] == 0) tll[i] = inf;
		if (a[i] < 0 && -a[i] < tll[i]) tll[i] = -a[i];
	}
	for (int i = N-1; i >= 0; --i) {
		tlr[i] = max(0, tlr[i+1]-1);
		if (a[i] == 0) tlr[i] = inf;
		if (a[i] < 0 && -a[i] < tlr[i]) tlr[i] = -a[i];
	}
	vector<int> tl(N);
	for (int i = 0; i < N; ++i) {
		tl[i] = max(tll[i], tlr[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
//		cout << tl[i] << " ";
		if (a[i] > 0) {
			ans += min(a[i], tl[i]);
		}
	}
//	cout << endl;
	cout << ans << endl;
}

Measured memory_bytes: 2588
a, b, c, d = map(int, input().split())
lst = sorted([a,b,c])
if(lst[1] - lst[0] <= d and lst[2] - lst[1] <= d):
    print("Yes")
else:
    if(a-c <= d and c-a <= d):
        print("Yes")
    else:
        print("No")

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int s = 60 * h1 + m1, e = 60 * h2 + m2;
  cout << e - s - k << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());

        int[][] values = new int[2][n];
        int[][] valuesSum = new int[2][n];

        StringTokenizer tokenizer;

        for (int i = 0; i < 2; i++) {
            tokenizer = new StringTokenizer(input.readLine());
            for (int j = 0; j < n; j++) {
                values[i][j] = Integer.parseInt(tokenizer.nextToken());
            }
        }

        valuesSum[0][0] = values[0][0];

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                    valuesSum[i][j] = values[i][j] + Math.max(getValues(i - 1, j, valuesSum), getValues(i, j - 1, valuesSum));
            }
        }

        System.out.println(valuesSum[1][n- 1]);

    }



    public static boolean checkIndex (int x, int y, int n){
        return x > -1 && y > -1 && x < 2 && y < n;
    }

    public static int getValues(int x, int y, int [][] values){

        if (checkIndex(x, y, values[0].length)){
            return values[x][y];
        }

        return 0;

    }
}


Measured memory_bytes: 21332