akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int n,m;
	cin>>n>>m;
	int sum=0;
	rep(i,m){
		int a;
		cin>>a;
		sum+=a;
	}
	int ans=n-sum;
	if(ans>=0){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
	//cout<<n-sum<<endl;
	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3664
#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>;

int main() {
  string s;
  int k;
  cin >> s >> k;
  rep(i, s.size()) {
    if (i == s.size()-1) {
      if (s[i] + k%26 > 'z') s[i] += k%26 - 26;
      else s[i] += k%26;
      break;
    }
    if (s[i] == 'a') continue;
    if (k < 'z' - s[i] + 1) continue;
    k -= 'z' - s[i] + 1;
    s[i] = 'a';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int n,k;
int cntl,cntr;
string s;
int ans;
map<int,int> mp;
int main(){
    cin >> n >> k;
    cin >> s;
    rep(i,n){
        if(s[i] == s[i+1]) ans++;
    }
    ans = min(n-1,ans+2*k);
    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3752
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        k : i64,
        n : i64,
    }
    let a = n - k + 1;
    let b = k + n;

    for i in a..b {
        print!("{}{}",i," ");
    }
    print!("{}","\n");

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  bool s,t;
  int ans=0;
  if(A<C)s=true;
  else s=false;
  if(B<D)t=true;
  else t=false;
  
  if(s&&t){
    if(B-C>0)cout<<B-C<<endl;
    else cout<<0<<endl;
  }
  else if(s&&!t)cout<<D-C<<endl;
  else if(!s&&t)cout<<B-A<<endl;
  else{
    if(D-A>0)cout<<D-A<<endl;
    else cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
	const int MAX = 100;
	int m[MAX], f[MAX],r[MAX];
	int i=0, max;
	
	do {
		cin >> m[i] >> f[i] >> r[i];
		i++;
	} while((m[i -1]!=-1)||(f[i-1]!=-1)||(r[i-1]!=-1)||(i==MAX));
	
	max = i - 1;
	
	for (int i = 0; i < max ; i++)
		if ((m[i]==-1)||(f[i]==-1))
			cout << 'F' << endl;
		else if (m[i] + f[i] >= 80)
			cout << 'A' << endl;
		else if (m[i] + f[i] >= 65)
			cout << 'B' << endl;
		else if (m[i] + f[i] >= 50)
			cout << 'C' << endl;
		else if (m[i] + f[i] >= 30) {
			if ( r[i] >= 50 )
				cout << 'C' << endl;
			else
				cout << 'D' << endl;
		}
		else
			cout << 'F' << endl;
	
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, K; cin >> N >> K;
  
  double ans = 0;
  repi(i,1,N) {
    int point = i;
    int m = 1;
    while(point < K) {
      point *= 2;
      m = point/i;
    }
    ans += 1.0/(double)m;
  }
  ans /= (double)N;
  
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const int N = 100 + 7;
const int INF = (int) 1e9;
int n;
int m;
int a[N][N];
int dp[N][N];
bool ok[N][N];

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

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) {
      a[i][j] = (s[j - 1] == '#');
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][1] = dp[1][0] = 0;
  for (int r = 1; r <= n; r++) {
    for (int c = 1; c <= m; c++) {
      int val = min(dp[r - 1][c], dp[r][c - 1]);
      ok[r][c] = 1;
      for (int i = r; i <= n; i++) {
        int go = c + (i == r);
        for (int j = go; j <= m; j++) {
          ok[i][j] = ((ok[i - 1][j] && a[i - 1][j] == a[i][j]) || (ok[i][j - 1] && a[i][j - 1] == a[i][j]));
        }
      }
      for (int i = r; i <= n; i++) {
        for (int j = c; j <= m; j++) {
          if (ok[i][j]) {
            dp[i][j] = min(dp[i][j], val + a[i][j]);
            ok[i][j] = 0;
          }
        }
      }
    }
  }
  cout << dp[n][m] << "\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[10][10],m,n,flag;
char kk[10];
void dfs(int x,int y){
    if(x==m-1&&y==n-1){
        for(int i=0;i<m;++i)for(int j=0;j<n;++j)if(a[i][j])return;
        flag=1;
        return;
    }
    if(flag==1)return;
    if(a[x+1][y]){
        a[x+1][y]=0;
        dfs(x+1,y);
        a[x+1][y]=1;
    }
    if(a[x][y+1]){
        a[x][y+1]=0;
        dfs(x,y+1);
        a[x][y+1]=1;
    }
    if(!a[x][y+1]&&!a[x+1][y])return;
}
int main(){
    scanf("%d%d",&m,&n);
    for(int i=0;i<=m;++i){
        gets(kk);
        for(int j=0;j<n;++j)if(kk[j]=='#')a[i-1][j]=1;
    }
    if(a[0][0]){
        a[0][0]=0;
        dfs(0,0);
    }
    if(flag)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define DOT(v1, v2) (v1.x * v2.x + v1.y * v2.y)
#define CROSS(v1, v2) (v1.x * v2.y - v1.y * v2.x)
#define NORM(v) (v.x * v.x + v.y * v.y)

typedef struct { double x, y; } point_t;
typedef point_t vector_t;
typedef struct { point_t p0, p1; } segment_t;
typedef segment_t line_t;

static vector_t plus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x + v2.x, v1.y + v2.y };
  return ret;
}

static vector_t minus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x - v2.x, v1.y - v2.y };
  return ret;
}

static vector_t multiple(vector_t v, double s) {
  vector_t ret = { v.x * s, v.y * s };
  return ret;
}

/*
 *                   s2.p1
 *                  /|
 *              1-t/ |h2
 *                /  |
 * s1.p0 ------------------- s1.p1
 *            |  /
 *          h1| /t
 *            |/
 *            s2.p0
 */
static point_t cross_point(segment_t s1, segment_t s2) {
  vector_t v1, v2;
  double h1, h2, t;

  v1 = minus(s1.p1, s1.p0);
  v2 = minus(s2.p0, s1.p0);
  h1 = CROSS(v1, v2); // h1 * ABS(v1)
  if (h1 < 0.0) h1 = -h1;
  v2 = minus(s2.p1, s1.p0);
  h2 = CROSS(v1, v2); // h2 * ABS(v1)
  if (h2 < 0.0) h2 = -h2;
  t = h1 / (h1 + h2); // reduce ABS(v1)
  return plus(s2.p0, multiple(minus(s2.p1, s2.p0), t));
}

int main(int argc, char **argv) {
  int q, i;
  segment_t s1, s2;
  point_t p;

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
        &s1.p0.x, &s1.p0.y, &s1.p1.x, &s1.p1.y,
        &s2.p0.x, &s2.p0.y, &s2.p1.x, &s2.p1.y);
    p = cross_point(s1, s2);
    printf("%.10lf %.10lf\n", p.x, p.y);
  }
}


Measured memory_bytes: 2108
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
      int P=sc.nextInt();
      int Q=sc.nextInt();
      int R=sc.nextInt();
      int a=0;
      int b=0;
      if (R>Q){
        a=R;
        R=Q;
        Q=a;
      }
      if(Q>P){
        b=Q;
        Q=P;
        P=b;
      }
      System.out.println(Q+R);
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
	int N;
	int h[100];
	int i,f,sum,color,max=0;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
		if(h[i]>=max)max=h[i];
	}
	
	int H[100];
	
	for(i=0;i<max;i++){
		//Hにバーコードを作成
		for(f=0;f<N;f++){
			if(h[f]==0){
			H[f]=0;
			//printf("0 ");
			}else{
			H[f]=1;
			h[f]-=1;;
			//printf("1 ");
			}
		}
		//バーコード読み取り
		if(H[0]==1){sum+=1;}
		
		for(f=1;f<N+1;f++){
			if(H[f-1]==0&&H[f]==1){sum+=1;
			}
		}
		//printf("\n");
	
	}
	printf("%d",sum);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    string s;
    cin >> s;
    set<char> st;
    for (auto i : s) st.insert(i);

    cout << (s.size() == st.size() ? "yes" : "no");

    return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
counts = Hash.new(0)
nums.each do |num|
  counts[num] += 1
end
values = counts.values.sort
kinds = values.size
ans = 0
if kinds <= k
  ans = 0
else
  ans += values[0...kinds - k].inject(:+)
end
puts ans


Measured memory_bytes: 32880
<?php
$count = intval(trim(fgets(STDIN)));
$a_score = 0;
$b_score = 0;

for ($i = 0; $i < $count; $i++) {
    fscanf(STDIN, "%s %s", $a, $b);
    if ($a < $b) {
        $b_score += 3;
    } elseif ($a > $b) {
        $a_score  += 3;
    } else {
        $a_score++;
        $b_score++;
    }
    
}

echo ("$a_score $b_score\n");
?>


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int R,P;
	int pi,ri;
	int ans=0;
	pi=s.size()/2;
	ri=s.size()-pi;
	R=0,P=0;
	for(int i=1;i<=s.size();i++)
	{
		if(s[i]=='g')
		R++;
		if(s[i]=='p')
		P++;
	}
	while(R>0)
	{
		if(pi>0)
		{
			pi--;
			R--;
			ans++;
		}
		if(pi<=0&&ri>0&&R>0)
		{
			R--;
			ri--;
		}
	}
	while(P>0)
	{
		if(pi>0)
		{
			pi--;
			P--;
		}
		if(pi<=0&&ri>0&&P>0)
		{
			P--;
			ri--;
			ans--;
		}
	}
	cout<<ans;
 } 

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int k,x;
    cin >> k >> x;
    if(500*k >= x) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  int sum=0;
  rep(i,n)sum+=s[i]-'0';
  n--;
  if(s[0]=='1')
    cout<<max(sum,9*n)<<endl;
  else 
    cout<<max(sum,9*n+(s[0]-'1'))<<endl;
}


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

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        String s = sc.next();
        int res = 0;
        for (int i = 0;i < s.length();i++) {
            if (s.charAt(i) == 'R') {
                res++;
            }
        }
        if (res == 3 || res <= 1) {
            pw.println(res);
        } else if (res == 2) {
            if (s.charAt(1) == 'R') {
                pw.println(2);
            } else {
                pw.println(1);
            }
        }
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32884
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int TakaHP = int.Parse(str[0]);
            int TakaAP = int.Parse(str[1]);
            int AokiHP = int.Parse(str[2]);
            int AokiAP = int.Parse(str[3]);

            int countTaka = 0;
            int countAoki = 0;

            do
            {
                AokiHP = AokiHP - TakaAP;
                countTaka += 1;

            } while (AokiHP > 0);
            do
            {
                TakaHP = TakaHP - AokiAP;
                countAoki += 1;

            } while (TakaHP > 0);

            if (countTaka <= countAoki)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 27380
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int a[5],k;
    for(int i=0;i<5;i++)
        cin>>a[i];
        cin>>k;
    int cnt=0;
    for(int i=0;i<5;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(abs(a[i]-a[j])>k){
                cnt++;
                break;
            }
        }
        if(cnt==1)
            break;
    }
    if(cnt!=1)
        cout<<"Yay!"<<'\n';
    else
        cout<<":("<<'\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    int ans[N];
    fill(ans, ans+N, 0);
    rep2(i, 1, N-1){
        rep2(j, i+1, N){
            int l;
            l = j-i;
            l = min(l, abs(X-i)+1+abs(Y-j));
            l = min(l, abs(Y-i)+1+abs(X-j));
            ans[l]++;
        }
    }
    rep2(i, 1, N-1) cout << ans[i] << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, T;
    scan(N, T);
    auto dp = new long[][](N + 1, 3000 * 3);
    auto Ai = new long[](N);
    auto Bi = new long[](N);
    foreach (i; 0 .. N)
    {
        long A, B;
        scan(A, B);
        Ai[i] = A;
        Bi[i] = B;
        foreach (j; 0 .. T)
        {
            dp[i + 1][j] = dp[i + 1][j].max(dp[i][j]);
            dp[i + 1][j + A] = dp[i + 1][j + A].max(dp[i][j] + B);
        }
    }
    long idx;
    long dpmax;
    foreach (i; 0 .. T)
    {
        if (dpmax < dp[N][i])
        {
            idx = i;
            dpmax = dp[N][i];
        }
    }
    long tmp = idx;
    long lastmax;
    foreach_reverse (i; 0 .. N)
    {
        if (dp[i + 1][tmp] == dp[i][tmp])
        {
            lastmax = lastmax.max(Bi[i]);
        }
        else
        {
            tmp = tmp - Ai[i];
        }
    }
    writeln(dpmax + lastmax);
}


Measured memory_bytes: 219004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	string s;
	vector<set<ll>>a(26);
	cin>>n>>s;
	ll m;
	cin>>m;
	for(ll i=0;i<n;i++){
		ll now=s[i]-'a';
		a[now].insert(i);
//		cout <<now<< " "<<i<<endl;
	}
	for(ll i=0;i<m;i++){
		ll now;
		cin>>now;
//		cout << now<<" ";
		if(now==2){
			ll cnt=0;
			ll l,r;
			cin>>l>>r;
			l--;r--;
			for(ll j=0;j<26;j++){
				auto itr=a[j].lower_bound(l);
								//	cout << *itr<< "itr"<<j<<"j"<<endl;
				if(itr!=a[j].end()&&*itr<=r){

					cnt++;
				}
			}
			cout << cnt<<endl;
		}
		if(now==1){
			ll l;char t;
			cin>>l>>t;
			l--;
			ll nex=t-'a';
			ll be=s[l]-'a';
			if(nex==be){
				continue;
			}
			s[l]=t;
			a[be].erase(l);
			a[nex].insert(l);
		}
	}
	// your code goes here
	return 0;
}


Measured memory_bytes: 24196
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <queue>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main(int argc,char* argv[])
{
    FASTIO


    int n,m,sum=0;
    cin>>n>>m;
    rep(i,m)
    {
        int x;cin>>x;
        sum+=x;
    }
    int ans = n-sum;
    if(ans<0)
        ans=-1;
    cout<<ans;



    return 0;
}



Measured memory_bytes: 3656
const calc = (str) => {
  const areas = [];
  const depthIndexes = [];
  let sum = 0;

  for (let i=0; i<str.length; i++) {
    const char = str[i];

    if (char === '\\') {
      depthIndexes.push(i);
      continue;
    }

    if (char === '/' && depthIndexes.length > 0) {
      const j = depthIndexes.pop();
      sum += i - j;
      let currentArea = i - j;
      while (areas.length > 0 && areas[areas.length-1].depth > j) {
        currentArea += areas[areas.length-1].area;
        areas.pop();
      }
      areas.push({
        depth: j,
        area: currentArea,
      });
    }
  }



  console.log(sum);
  if (areas.length === 0) {
    console.log(0);
    return;
  }
  console.log(`${areas.length} ${areas.map(obj => obj.area).join(' ')}`);
};


let inputStr = '';
process.stdin.on('data', (input) => { inputStr += String.raw`${input}` });

process.stdin.on('end', () => { calc(inputStr); });


Measured memory_bytes: 18412
#include<iostream>
#include<queue>
using namespace std;
int main() {
	long long int N, M;
	long long int ans = 0;
	priority_queue<long long int> q;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		long long int a = 0;
		cin >> a;
		ans += a;
		q.push(a);
	}
	for (int i = 0; i < M; i++) {
		q.push(q.top() / 2);
		ans -= (q.top() + 1) / 2;
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <algorithm>

const int MAXN = 1e5 + 5;

int a [MAXN];

int main ()
{
	int n, p;
	scanf ("%d", &n);
	
	for (int i = 1; i <= n; i ++)
		scanf ("%d", &a [i]);
		
	std::sort (a + 1, a + n + 1, std::greater <int> ());
			
	for (int i = 1; i <= n; i ++)
		if (i + 1 > a [i + 1])
		{
			int j;
			
			for (j = 0; a [i + j + 1] == i; j ++);
			
			if ((a [i] - i) % 2 || j % 2)
				puts ("First");
			
			else
				puts ("Second");
				
			return 0;
		}
}

Measured memory_bytes: 3468
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main(){
    IOS;
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i,n){
        cin >> h[i];
    }
    sort(all(h));
    int res = INT_MAX;
    REP(i,n-k+1){
        chmin(res,h[i+k-1]-h[i]);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new A();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class F implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{

		}
	}

	static class E implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{

		}
	}

	static class D implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{

		}
	}
	
	static class C implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{

		}
	}
	
	static class B implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{

		}
	}

	static class A implements Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{
			int n = in.nextInt();
			int q = in.nextInt();
			UnionFind tree = new UnionFind(n);
			for( int i=0; i<q; i++ )
			{
				int t = in.nextInt();
				int u = in.nextInt();
				int v = in.nextInt();
				if( t == 0 )
				{
					tree.unite(u, v);
				}
				else
				{
					out.println(Integer.toString(tree.same(u, v) ? 1 : 0));
				}
			}
		}
	}

	static class UnionFind
	{
		int[] par;
		int[] n_nodes;
		int max = 1;
		
		public UnionFind(int n)
		{
			par = new int[n];
			n_nodes = new int[n];
			for( int i=0; i<n; i++ )
			{
				par[i] = i;
				n_nodes[i] = 1;
			}
		}
		
		int root(int x)
		{
			if( par[x] == x ) return x;
			return par[x] = root(par[x]);
		}
		
		void unite(int x, int y)
		{
			int rx = root(x);
			int ry = root(y);
			if( rx == ry ) return;
			par[rx] = ry;
			n_nodes[ry] += n_nodes[rx];
			max = Math.max(max, n_nodes[ry]);
		}
		
		boolean same(int x, int y)
		{
			int rx = root(x);
			int ry = root(y);
			return rx == ry;
		}
	}
	
	static class MyScanner
	{
		private BufferedReader in;
		private StringTokenizer st;
		
		public MyScanner(InputStream stream)
		{
			in = new BufferedReader(new InputStreamReader(stream));
		}
		
		public String next()
		{
			while( st == null || !st.hasMoreTokens() )
			{
				try
				{
					String rl = in.readLine();
					if( rl == null )
					{
						return null;
					}
					st = new StringTokenizer(rl);
				}
				catch( IOException e )
				{
					return null;
				}
			}
			return st.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
		
		public long nextLong()
		{
			return Long.parseLong(next());
		}
	}
	
	static interface Solver
	{
		public void solve(int testNumber, MyScanner in, PrintWriter out);
	}
}


Measured memory_bytes: 56448
function Main(input) {
  "use strict";
  const lines = input.split("\n");
  const line1 = lines[0].split(" ");

  const n = parseInt(line1[0], 10);
  const a = parseInt(line1[1], 10);
  const b = parseInt(line1[2], 10);

  var total = 0;
  var sum = 0;
  for (let i = 1; i <= n; i++) {
    const ns = i.toString().split("").map(s => +s)
    sum = 0;
    for (let k = 0; k < ns.length; k++) {
      sum += ns[k]
    }
    if (a <= sum && sum <= b) {
      total += i
    }

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


Measured memory_bytes: 33892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)

int factor[1003] = {0};

void factoring(int N){
    for(int i = 2; i <= N; i++){
        while(1){
            if(N%i != 0){
                break;
            }
            N = N/i;
            factor[i]++;
        }
    }
}

int main(){
    ll N;
    cin >> N;

    if(N==1){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 2; i <= N; i++){
        factoring(i);
    }

    ll result=1;


    for(int i = 0; i < 1003; i++){
        if(factor[i]!=0){
            //printf("factor[%d] : %d\n",i,factor[i]);
        }
        result = ((result%modmod) * ((factor[i]+1)%modmod))%modmod;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int T[1000010];

int main () {
        int n, c, k;
        cin >>  n >> c >> k;
        for (int i = 1; i <= n; i++)
                cin >> T[i];
        sort (T + 1, T + n + 1);
        int ans = 1, now = 1, b = T[1];
        for (int i = 2; i <= n; i++) {
                if (now == c || T[i] - b > k) {
                        ans++;
                        now = 1;
                        b = T[i];
                } else {
                        now++;
                }
        }
        printf ("%d\n", ans);
        return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int N;
    cin >> N;

    bool flag = false;
    for (int i = 1; i <= 9; ++i) {
        for (int k = 1; k <= 9; ++k) {
            if (i * k == N) {
                flag = true;
                break;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector a(0L, 0L);
    bool has_zero = false;
    for (auto _ : irange(0L, n)) {
        int64_t aa;
        cin >> aa;

        if (aa != 0) {
            a.push_back(aa);
        } else {
            has_zero = true;
        }
    }

    n = a.size();
    if (n < k) {
        cout << 0 << endl;
        return 0;
    }

    sort(a.rbegin(), a.rend(),
         [](int64_t x, int64_t y) { return abs(x) < abs(y); });

    int64_t s = 1, prod = 1, prodp = 1, prodn = 1, mp = -1, mn = -1;
    constexpr auto M = 1000000007L;
    for (auto i : irange(0L, k) | reversed) {
        if (a[i] < 0) {
            s *= -1;
            if (mn < 0) {
                mn = -a[i];
            } else {
                prodn *= -a[i];
            }
            prodp *= -a[i];
        } else {
            if (mp < 0) {
                mp = a[i];
            } else {
                prodp *= a[i];
            }
            prodn *= a[i];
        }

        prod *= abs(a[i]);
        prod %= M;
        prodn %= M;
        prodp %= M;
    }

    int64_t ans = 1;
    if (s > 0) {
        ans = prod;
    } else {
        auto itn = find_if(a.begin() + k, a.end(),
                           [](int64_t aa) { return aa < 0; });

        if (mp < 0 || itn == a.end()) {
            prodp = -1;
        } else {
            prodp *= -*itn;
            prodp %= M;
        }

        auto itp = find_if(a.begin() + k, a.end(),
                           [](int64_t aa) { return aa > 0; });

        assert(mn > 0);
        if (itp == a.end()) {
            prodn = -1;
        } else {
            prodn *= *itp;
            prodn %= M;
        }

        if (prodp > 0 && prodn > 0) {
            if (-*itn * mn > *itp * mp) {
                prodn = -1;
            } else {
                prodp = -1;
            }
        }

        if (prodp > 0) {
            ans = prodp;
        } else if (prodn > 0) {
            ans = prodn;
        } else if (has_zero) {
            ans = 0;
        } else {
            assert(itp == a.end() && (k == n || mp < 0));
            for (auto i : irange(0L, k)) {
                ans *= abs(a[n - i - 1]);
                ans %= M;
            }
            ans = (M - ans);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5324
S = input()
dates = (("SUN", 7),
         ("MON", 6),
         ("TUE", 5),
         ("WED", 4),
         ("THU", 3),
         ("FRI", 2),
         ("SAT", 1),
         )
for date in dates:
    if S == date[0]:
        print(date[1])

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

int main(){
    int n;
    int ans=0;
    string s;
    cin >> n >> s;
    for(int i=1;i<=n-1;i++){
        int same=0;
        string x=s.substr(0,i);
        string y=s.substr(i,n-i);
        vector<bool>a(26,false);
        vector<bool>b(26,false);
        for(int p=0;p<x.size();p++) a[x[p]-'a']=true;
        for(int p=0;p<y.size();p++) b[y[p]-'a']=true;
        for(int p=0;p<26;p++){
            if(a[p]==true&&b[p]==true) same++;
        }
        ans=max(ans,same);
    }
    cout << ans << endl;
    return 0;
}

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

int p[200010], d[200010];
int main()
{
    int n; cin>>n;
    for(int i=0; i<n; ++i) cin>>p[i];

    for(int i=0; i<n; ++i)
        d[p[i]]=d[p[i]-1]+1;
    cout<<n-*max_element(d, d+n+1)<<endl;
}


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

int par[100005];
int Rank[100005];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        Rank[i]=0;
    }
}
//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
//ｘとｙの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y]) Rank[x]++;
    }
}
//ｘとｙが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}

int main(void){
    int n,m,x,y,z,ans=0;cin>>n>>m;
    init(n);
    for(int i=0;i<m;i++){
        cin>>x>>y>>z;
        unite(x,y);
    }
    for(int i=0;i<n;i++){
        if(par[i]==i)ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long a = sc.nextLong();
    static long b = sc.nextLong();
    static long c = sc.nextLong();
    static long k = sc.nextLong();

    public static void main(String[] args) {
        long result = 0;
        long tmp = k - a;
        if (tmp > 0){
            result = a;
            tmp = tmp - b;
            if (tmp > 0){
                result = result - tmp;
            } else {
                result = a;
            }
        } else {
            result = k;
        }
        System.out.println(result);

    }
}


Measured memory_bytes: 35744
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        int H = sc.nextInt();
	        int W = sc.nextInt();
	        int K = sc.nextInt();
	        char[][] m= new char[H][W];
	        for(int i=0;i<H;i++) {
	        	String S = sc.next();
	        	m[i]=S.toCharArray();
	        }
	        
	        
	        long ans=0;
	        int n = (int)Math.pow(2, H+W);
	        for(int i=0;i<n;i++) {
	        	int cnt=0;
	        	for(int j=0;j<H;j++) {
	        		for(int k =0;k<W;k++) {
	        			if(((i>>j)%2)==0&&((i>>(H+k))%2)==0) {
	        				if(m[j][k]=='#') {
	        					cnt++;
	        				}
	        				
	        			}
	        		}
	        	}
	        	if(cnt==K)ans++;
	        }
	        
	        System.out.println(ans);

		 }
	}

Measured memory_bytes: 35788
n,m,q = map(int,input().split())
query = [[0 for j in range(501)] for i in range(501)]

for h in range(m):
    k,l = map(int,input().split())
    query[k][l] += 1

#リストを累積和にする
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i][j-1]
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i-1][j]
        

for h in range(q):
    k,l = map(int,input().split())
    A,B,C = 0,0,0
    if k > 1:
        A = query[k-1][l]
        B = query[l][k-1]
        C = query[k-1][k-1]
    print(query[l][l] - A - B + C)

Measured memory_bytes: 58712
#include <stdio.h> 

int main(void){ 
    int X;
    int A;
    int B; 
    
 
    scanf("%d", &X); 
    scanf("%d", &A); 
    scanf("%d", &B); 

    if(B - A <= X){

        if(B - A <= 0){

          printf("delicious");
 
        }else{

          printf("safe");

        }

    }else{
    
        printf("dangerous");
  
   }

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LOCAL
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    string ans = "";
    while(n){
        int tmp = (n-1)%26;
        //trace(n,tmp);
        ans = (char)('a' + tmp) + ans;
        n--;
        n /= 26;

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)


signed main () {
  int K,A,B;
  bool can=false;
  cin >> K >> A >> B;
  for(int i=0;i<INF;i++){
    if(A<=K*i&&K*i<=B){
      can=true;
    }else if(K*i>B){
      break;
    }
  }
  if(can){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int N, X;
	cin >> N >> X;

	vector<int> v(N);
	int c = 0;

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		if (!i) v[i] = n;
		else v[i] = v[i - 1] + n;
		if (v[i] <= X) c++;
	}

	cout << ++c << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <climits>

using namespace std;

const int N = 3e5 + 5000;
int n, m, T, ans;

int main()
{
#ifdef ONLINE_JUDGE
#else
   // freopen("r.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);

    cin >> n >> m;

    while (n)
    {
        n /= m;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end(),greater<int>());
	int sum = 0;
	for (int i = 0; i <k; i++) {
		sum += a.at(i);
	}
	cout << sum << endl;
}



Measured memory_bytes: 256