akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt[ohara], ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> m;
  rep(i, n) {
    cin >> k;
    rep(j, k) {
      cin >> a;
      a--;
      cnt[a]++;
    }
  }
  rep(i, m) {
    if (cnt[i] == n) ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define null NULL
#define S 100005
#define INF 100000000000
typedef long long int lli;
#define newline cout<<"\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)

lli dp[300][S];

void ans(lli *v,lli *wt,lli n,lli tw)
{
    lli i,j;
    for(i=0;i<=n;i++)
    for(j=0;j<=tw;j++)
   { 
      if(j==0)
      dp[i][j]=0;
      else
      dp[i][j]=INF;
   }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=tw;j++)
        {
            if(v[i-1]<=j)
            dp[i][j]=min(wt[i-1]+dp[i-1][j-v[i-1]],dp[i-1][j]);
            else  
            dp[i][j]=dp[i-1][j];
        }
    }

}

int main()
{
    lli n,w,i,tw=0,tv=0;
    cin>>n>>w;
    lli wt[n],v[n];
    for(i=0;i<n;i++)
    {
    cin>>wt[i]>>v[i];
    tw=tw+v[i];
    tv=tv+wt[i];
    }
    ans(v,wt,n,tw);
    for(i=tw;i>=0;i--)
    {
        if(dp[n][i]<=w)
        {
          //cout<<dp[n][i]<<"\n";
           cout<<i;
            return 0;
        }
    }
  
}


Measured memory_bytes: 80128
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

long long find_min(function<bool(long long)> solve, long long low, long long high) {
	long long ng = low, ok = high;
	while (ok - ng > 1) {
		long long mid = (ok + ng) / 2;
		if (solve(mid)) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	return ok;
}

int main() {
	long long n, k;
	cin >> n >> k;
	vector<long long> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	function<bool(long long)> f = [&](long long x) {
		long long l = 0;
		for (int i = 0; i < n; i++) {
			l += (A[i] + x - 1) / x - 1;
		}
		if (l <= k) return true;
		else return false;
	};
	long long ans = find_min(f, 0, 1001001001);
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e5) + 5;
const int MAX_A = int(15e6);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

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

int main() {
    int n, l;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        if(i==0) l = a;
        l = a*l/gcd(a,l);
    }
    cout << l << endl;
    return 0;
}



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

using ll = long long;

#define SQR(x) (x) * (x)

int main(){
    int a, b;
    cin >> a >> b;
    int count = 0;
    count += a - 1;
    if(a <= b){
        count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;
typedef pair<ll, Pa> program;

vector<program> info;
vector<program> programs;

int time_sum[100001];
int main() {
	cin >> N >> C;
	rep(i, N) {
		cin >> A >> B >> D; A--; B--;
		info.push_back(program(D, Pa(A, B)));
	}
	sort(info.begin(), info.end());
	int left = info[0].second.first;
	int prev = info[0].second.second;
	int ch = info[0].first;
	rep(i, N - 1) {
		if (ch == info[i + 1].first && prev == info[i + 1].second.first) {
			prev = info[i + 1].second.second;
		}
		else {
			programs.push_back(program(ch, Pa(left, prev)));
			left = info[i + 1].second.first;
			prev = info[i + 1].second.second;
			ch = info[i + 1].first;
		}
	}
	programs.push_back(program(ch, Pa(left, prev)));
	memset(time_sum, 0, 100001);
	rep(i, programs.size()) {
		time_sum[programs[i].second.first]++;
		time_sum[programs[i].second.second + 1]--;
	}
	int maxv = 0;
	rep(i, 100000) {
		time_sum[i + 1] += time_sum[i];
		maxv = max(maxv, time_sum[i + 1]);
	}
	cout << maxv;
}


Measured memory_bytes: 8432
// C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;

int wa_count[100000];

int main(){
	int n,m,p,ac=0,wa=0;
	char s[3];
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%s",&p,s); --p;
		if(wa_count[p] < 0) continue;// ac
		if(s[0] == 'W') wa_count[p]++;
		else{
			ac++;
			wa += wa_count[p];
			wa_count[p] = -1;// ac flag on
		}
	}
	printf("%d %d\n",ac,wa);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    for (int i = X; ; ++i) {
        auto prime = [&]() {
            for (int j = 2; j * j <= i; ++j) {
                if (i % j == 0) return false;
            }
            return true;
        }();
        if (prime) {
            cout << i << endl;
            break;
        }
    }
}

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


using ll =  long long;

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

using namespace std;

int main(){

    int k, n;
    cin >> k>> n;
    
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    a.push_back(a[0]+k);
    int l=0;
    rep(i,n){
        l = max(l, a[i+1]-a[i]);
    }
    int ans = k-l;
    cout << ans << endl;


    
    return 0;
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (n, m) = sc.nextLine().split(" ").map { it.toInt() }
    val a = (1..n).map { sc.nextLong() }.sortedDescending()

    println(if(a[m-1]>= a.sum()/(4.0*m)) "Yes" else "No")
}

Measured memory_bytes: 36172
import sys
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

if N == 1 and M == 0:
    print(0)
    sys.exit()
if N == 1 and sc[0][1] == 0:
    print(0)
    sys.exit()

A = [-1] * N
for i in range(M):
    if sc[i][0] == 1 and sc[i][1] == 0:
        print('-1')
        sys.exit()
    if A[sc[i][0] - 1] != -1 and A[sc[i][0] - 1] != sc[i][1]:
        print('-1')
        sys.exit()
    A[sc[i][0] - 1] = sc[i][1]
if A[0] == -1:
    A[0] = 1
for a in A:
    if a == -1:
        a = 0
    print(a, end='')
print('')

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

int main(int argc, char **argv){
	int W = 0;
	int H = 0;
	int x = 0;
	int y = 0;
	int r = 0;
	int tmpW = 0;
	int tmpH = 0;

	std::cin >> W >> H >> x >> y >> r;

	tmpW = W - r;
	tmpH = H - r;

	if(r <= x && x <= tmpW && r <= y && y <= tmpH){
		std::cout << "Yes";
	}
	else{
		std::cout << "No";
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
const int N=1e5+5;
int n,k,a[N],b[N],c[N],now,tot,ans,sum;
char s[N];
int main() {
	n=_; k=_;
	scanf("%s",s+1);
	for( int i=1;i<=n;i++ ) a[i]=s[i]-'0';
	// for( int i=1;i<=n;i++ ) cout<<a[i]<<" ";
	for( int i=1,j;i<=n;i=j ) {
		tot++;
		for( j=i+1;j<=n;j++ ) if(a[j]!=a[i]) break;
		b[tot]=j-i; c[tot]=(a[i]^1); 
	}n=tot;
	// for( int i=1;i<=n;i++ ) cout<<b[i]<<" ";
	queue<int>q;
	for( int i=1;i<=n;i++ ) {
		now+=c[i];
		while(now>k&&!q.empty()) { now-=c[q.front()]; sum-=b[q.front()]; q.pop(); }
		sum+=b[i];
		ans=max(ans,sum);
		q.push(i);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int mape[505][505];
int ans[505][505];
int ans2[505][505];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m,q;
	cin>>n>>m>>q;
	memset(mape,0,sizeof(mape));
	memset(ans,0,sizeof(ans));
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		mape[l][r]++;
	}
	for(int i=1;i<=500;i++){
		for(int j=1;j<=500;j++){
			ans[i][j]=ans[i][j-1]+mape[i][j]; 
		}
	}
	for(int i=500;i>=1;i--){
		for(int j=1;j<=500;j++){
			ans[i][j]+=ans[i+1][j]; 
		}
	}
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		cout<<ans[l][r]<<endl;
	}
} 

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  long double a,b,h,m,c; cin>>a>>b>>h>>m;
  h=h*30+m/2; m*=6;
  c=min(  (abs(h-m)) ,  360- (abs(h-m)) );
  
  //cout<<c<<endl;
  
  cout << fixed << setprecision(11);
  cout<<sqrt(a*a +b*b - 2*a*b*cos((c*3.14159265359/180)));

}


Measured memory_bytes: 4164
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
        int A, B, C, D, E, K;
        cin >> A >> B >> C >> D >> E >> K;
        cout << (E - A <= K ? "Yay!" : ":(") << endl;
        return 0;


}


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

int main()
{
	int n = 0;
	scanf("%d", &n);
	int x = 0;
	scanf("%d", &x);
	
	int min = x;

	int a[100];
	for (int i = 0; i < n; i++) {scanf("%d", &a[i]); x = x - a[i]; if (a[i] < min) min = a[i];}
	
	int t = 0;
	while (x >= 0) {
		x = x - min;
		t++;
	}
	int ans = n + t - 1;
	printf("%d\n", ans);
}

Measured memory_bytes: 128
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d

n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort.reverse

class Stick
  def initialize(length, index)
    @length = length
    @index = index
  end

  attr_reader :length, :index
end

sticks = l.map.with_index(0) { |length, i| Stick.new(length, i) }

# puts sticks.inspect
# puts ""

count = 0
0.upto(n - 3) do |i|
  a = sticks[i]
  (i + 1).upto(n - 2) do |j|
    b = sticks[j]
    c_candidates = sticks[(j + 1)..(n - 1)]
    t = a.length - b.length
    c_over = c_candidates.bsearch { |stick| stick.length <= t }
    if c_over.nil?
      c_last_index = n - 1
    else
      c_last_index = c_over.index - 1
    end
    # puts "--------"
    # puts c_candidates.inspect
    # puts "a: #{a}, b: #{b}, a - b: #{t} -> #{c_last_index - j}"
    # puts ""
    count += c_last_index - j
  end
end

puts count


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

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

  int ans = 0;
  for(int i=1; i<=n; i++) {
    int sum = 0;
    int t = i;
    while(t > 0) {
      sum += t % 10;
      t /= 10;
    }
    if(a <= sum && sum <= b) ans += i;
  }

  cout << ans << endl;
}

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


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    int T;
    T = 1;
    while (T--) solve();
}

// https://www.youtube.com/watch?v=br3ze-KC6WA
// 連結成分内では 1 点の値を決めれば自動的にすべての頂点の数が決まる
void solve() {
    int n, m;
    cin >> n >> m;
    
    vector<vector<pii> > G(n);
    rep(i, m) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].eb(r, d);
        G[r].eb(l, -d);
    }
    
    vector<int> x(n), used(n);
    auto dfs = [&](auto&& dfs, int v, int p) -> void {
        for (pii np : G[v]) {
            int nv = np.F, cost = np.S;
            // cout << nv << " " << cost << endl;
            
            if (used[nv] == 1) {
                if (x[nv] != x[v] + cost) {
                    // cout << x << endl;
                    cout << "No" << endl;
                    exit(0);
                }
            } else {
                x[nv] = x[v] + cost;
                used[nv] = 1;
                dfs(dfs, nv, v);
            }
        }
    };
    
    rep(i, n) {
        if (used[i]) continue;
        used[i] = 1;
        dfs(dfs, i, -1);
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 11392
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)


typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    int K; cin >> K;
    set<int> D;
    repp(i, 0, K) {
        int d; cin >> d;
        D.insert(d);
    }
    long long res = N;
    while(true) {
        bool ok = true;
        long long t_res = res;
        while(t_res > 0) {
             ok &= D.find(t_res % 10) == D.end();
             t_res /= 10;
        }
        if (ok) {
            cout << res << endl;
            return 0;
        } else {
            ++res;
        }
    }
}

Measured memory_bytes: 256
h={};n=gets.to_i;a=[*0...n];b=gets.split.map(&:to_i)[1..-1]
(1<<a.size).times{|i|x=0;y=[];a.size.times{|j|i[j]>0&&(x+=1<<a[j];y<<a[j])};y&b==b&&h[x]=y}
puts h.sort.map{|k,v|k.to_s+':'+v.map{|e|' %d'%e}*''}


Measured memory_bytes: 130196
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		String textString = scan.next();
		char[] text=textString.toCharArray();
		int num =scan.nextInt();
		int A =0;
		int B =0;
		String repText= "";
		String syutu ="";
		for (int j=0; j<num; j++){
			String decree =scan.next();
			A = scan.nextInt();
			B = scan.nextInt();
			if(decree.equals("replace")){
				repText = scan.next();
				for(int i=0; i<(B-A+1); i++){
					text[A+i] = repText.charAt(i);
				}
			}
			if(decree.equals("reverse")){
				char[] hozon = (char[])text.clone();
				for(int i=0; i<B-A+1; i++){
					text[B-i] = hozon[i+A];
				}
			}
			if(decree.equals("print")){
				syutu = "";
				for(int i=A; i<B+1; i++){
					syutu = syutu + text[i];
				}
				System.out.println(syutu);
				
			}
		}

	}
}

Measured memory_bytes: 45620
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000

int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<long long> a(N);
	rep(i,N)cin>>a[i];
	
	long long ans = Inf;
	rep(i,(1<<N)){
		vector<long long> b = a;
		int c = 0;
		long long maxi = 0;
		long long sum =0LL;
		rep(j,N){
			if((i>>j)&1){
				c++;
				if(maxi>=b[j]){
					sum += maxi+1-b[j];
					b[j] = maxi+1;
				}
				
			}
			maxi = max(maxi,b[j]);
		}
		if(c>=K)ans = min(ans,sum);
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

LL x;

int main() {
    GLL(x);

    LL n = 0;

    while (n * (n+1) / 2 < x) n++;

    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

lli a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	cin >> a >> b >> c;
	lli tmp = max(a, b);
	lli ans = c / tmp;
	if(c % tmp != 0) ans ++;
	cout << ans;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    vector<int> as(n);
    for(int i=0;i<n;i++){
        cin >> as[i];
    }
    ll ans = MLL;
    for(int h=0;h<2;h++){
        ll cand = 0, sum = 0;
        for(int i=0;i<n;i++){
            sum += as[i];
            if((i & 1) ^ h){
                if(sum <= 0){
                    cand += max(- sum + 1, 0ll);
                    sum = 1;
                }
            }else{
                if(sum >= 0){
                    cand += max(sum + 1, 0ll);
                    sum = -1;
                }
            }
        }
        ans = min(ans, cand);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int a,b,m;
  cin >> a >> b >> m;
  int u=inf,uu=inf;
  vector<int> aa(a),bb(b);
  rep(i,a){
    cin >> aa[i];
    u=min(aa[i],u);
  }
  rep(i,b){
    cin >> bb[i];
    uu=min(bb[i],uu);
  }
  int ans=u+uu;
  rep(i,m){
    int f,g,h;
    cin >> f >> g >> h;
    ans=min(ans,aa[f-1]+bb[g-1]-h);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

string field[10];


int main(){
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  rep(i,H){
    cin >> field[i];
  }

  bool flg = true;
  field[0][0]='@';
  while(field[H-1][W-1]=='#'){
    bool check = false;
    rep(i,H){
      rep(j,W){
        if(field[i][j]=='@'){
          int cnt = 0;
          if(i+1<H && field[i+1][j]=='#'){
            field[i+1][j]='@';
            cnt++;
            check = true;
          }
          if(j+1<W && field[i][j+1]=='#'){
            field[i][j+1]='@';
            cnt++;
            check = true;
          }
          if(cnt==2) flg = false;
        }
      }
    }
    if(!check) flg = false;
    if(!flg) break;
  }

  rep(i,H){
    rep(j,W){
      if(field[i][j]=='#') flg = false;
    }
  }
  
  if(flg){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  
  return 0;
}



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

typedef long long ll;
const int N = 100005;

int n, m, top;
ll a[N], stk[N], f[N], s[N];

// [1, i] repeat j times. 

void work(ll i, ll j)
{
	if(i <= a[1])
	{
		s[1] += j;
		s[i + 1] -= j;
		return;
	}
	int p = lower_bound(a + 1, a + 1 + m, i) - a - 1;
	f[p] += j * (i / a[p]);
	work(i % a[p], j);
}

int main()
{
	scanf("%d %d", &n, &m);
	stk[top = 1] = n;
	for(int i = 1; i <= m; ++i)
	{
		ll x;
		scanf("%lld", &x);
		for(; top && stk[top] >= x; --top);
		stk[++top] = x;
	}
	m = top;
	copy(stk, stk + m + 1, a);
	f[m] = 1;
	a[0] = 4e18;
	for(int i = m; i; --i)
		if(f[i])
			work(a[i], f[i]);
	for(int i = 1; i <= n; ++i)
	{
		s[i] += s[i - 1];
		printf("%lld\n", s[i]);
	}
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int MAX = 100005;

int main(){
    vector<int> isprime(MAX, 1);
    isprime[0] = 0;
    isprime[1] = 0;
    for(int i = 2; i < MAX; ++i){
        if(!isprime[i]) continue;
        for(int j = i*2; j < MAX; j+=i){
            isprime[j] = 0;
        }
    }
    vector<int> a(MAX, 0);
    for(int i = 0; i < MAX; i++){
        if(i % 2 == 0) continue;
        if(isprime[i] && isprime[(i+1)/2]) a[i] = 1;
    }
    vector<int> s(MAX+1, 0);
    for(int i = 0; i < MAX; i++){
        s[i+1] = s[i] + a[i];
    }
    int q; cin >> q;
    rep(i,q){
        int l, r; cin >> l >> r;
        r++;
        cout << s[r] - s[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#define rep(i,n) for(i = 0;i < n;i++)
using namespace std;

int m,e,j;

int main(){
	int n,i;
	while( cin >> n ){
		if( n == 0 )
			break;
		rep(i,n){
			cin >> m >> e >> j;
			//上から順に振り分け
			if( max(m,max(e,j)) == 100 || (m+e) >= 180 || (m+e+j) >= 240 ){
				cout << "A" << endl;
			}
			else if( m+e+j >= 210 || ( (m >= 80 || e >= 80) && m+e+j >= 150 ) ){
				cout << "B" << endl;
			}
			else
				cout << "C" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

int main(){
    int a,b;
    std::cin>>a;
    std::cin>>b;
    if((-1000<=a)&&(-1000<=b)&&a<=1000&&b<=1000){
    if(a<b){
        std::cout<<"a < b"<<std::endl;
    }
    else if(a>b){
        std::cout<<"a > b"<<std::endl;
    }else if(a==b){
        std::cout<<"a == b"<<std::endl;
    }
}
}



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

#define int long long

const int N = 100, lim = 89;
const int P = 1e9 + 7;

struct Node {
  int x, y;
};

std::vector<Node> vec[N];
int fib[N];

inline void init() {
  fib[0] = fib[1] = 1;
  for (int i = 2; i <= lim + 1; ++i)
    fib[i] = fib[i - 1] + fib[i - 2];

  vec[1].push_back({ 1, 2 });
  vec[1].push_back({ 1, 3 });
  vec[1].push_back({ 1, 4 });

  for (int i = 2; i <= lim; ++i) {
    // cerr << i << endl;
    for (auto a : vec[i - 1]) {
      int y = a.y, x = a.x + y;
      while (x <= fib[i + 2] + fib[i - 1] && y <= fib[i + 2] + fib[i - 1]) {
        vec[i].push_back({ y, x });
        x += y;
      }
    }
  }

  /*
  for (int i = 1; i <= 10; ++i) {
    cerr << i << " : ";
    for (auto a : vec[i]) {
      printf("(%lld, %lld) ", a.x, a.y);
    }
    cerr << endl;
  }
  */

}

inline void solve(int n, int m) {

  if (n == 1) {
    printf("1 %lld\n", m % P);
    return;
  }
  if (n == 2 && m == 2) {
    puts("1 4");
    return;
  }

  int ans = 0;
  for (int i = 1; i <= lim; ++i) {
    if (fib[i] <= n && fib[i + 1] <= m) {
      ans = i;
    } else {
      break;
    }
  }

  int cnt = 0;

  for (auto w : vec[ans - 1]) {
    int x = w.x, y = w.y;
    // cerr << x << " " << y << endl;
    if (y <= m)
      cnt = (cnt + (n - x) / y) % P;
    if (y <= n)
      cnt = (cnt + (m - x) / y) % P;
  }

  printf("%lld %lld\n", ans, (cnt % P + P) % P);

}

signed main() {
  // freopen("data", "r", stdin);
  // freopen("1.out", "w", stdout);
  init();
  int q; std::cin >> q;
  while (q--) {
    int x, y; scanf("%lld %lld", &x, &y);
    if (x > y) std::swap(x, y);
    solve(x, y);
  }
  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
bool table[10][10];
int dfs(int pos, int n, bool visited[10])
{
	bool ok = true;
	for(int i = 0; i < n; i++)
	{
		if(visited[i] == false) ok = false;
	}
	if(ok) return 1;
	int ret = 0;
	for(int i = 0; i < n; i++)
	{
		if(visited[i] == true) continue;
		if(table[pos][i] == false) continue;
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int a, b;
	for(int i = 0; i < m; i++)
	{
		cin >> a >> b;
		a--; b--;
		table[a][b] = table[b][a] = true;
	}
	bool visited[n + 1];
	for(int i = 0; i < n + 1; i++)
	{
		visited[i] = false;
	}
	visited[0] = true;
	int ans = dfs(0, n, visited);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
edge = Array.new(n+1).map{Array.new}
(n-1).times do
    a, b, c  = gets.chomp.split(" ").map(&:to_i)
    edge[a] << [b, c]
    edge[b] << [a, c]
end

q, k = gets.chomp.split.map(&:to_i)

cost = Array.new(n+1,Float::INFINITY)
done = Array.new(n+1,false)

queue = [k]
done[k] = true
cost[k] = 0
while(queue.size > 0)
    v = queue.pop
    
    edge[v].each do |i, j|
        if done[i] == false
            done[i] = true
            cost[i] = cost[v] + j if cost[i] > cost[v] + j
            queue.push(i)
        else
        end
    end
end

q.times do
    x, y = gets.chomp.split.map(&:to_i)
    puts cost[x] + cost[y]
end


Measured memory_bytes: 29820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> v(100005);
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    priority_queue<int> p_que;
    ll ans = 0;
    for(int i=1;i<=M;i++){
        for(int x : v[i]) p_que.push(x);
        if(p_que.empty()) continue;
        ans += p_que.top();
        p_que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
n,m,v,p,*a=map(int,open(0).read().split())
a=sorted(a)[::-1]
ok=p-1
ng=n
while ng-ok>1:
  mid=(ok+ng)//2
  c=a[mid]+m
  s=f=0
  for t in a[p-1:mid]:
    if t>c:break
    s+=c-t
  else:f|=(p-1+n-mid)*m+s>=v*m
  if f:ok=mid
  else:ng=mid
print(ok+1)

Measured memory_bytes: 69800
#include <stdio.h>
int main()
{
	int N, R, v, z, x;
	scanf("%d %d", &N, &R);
	v = R + 100*(10-N);
	if ( N >= 10 ){
		printf("%d", R);
	}
	else {
		printf("%d", v);
	}
	return 0;
}

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  int n,k;
  cin>>n>>k;
  int x[100005];
  for (int i=0; i<n; i++) {
    cin>>x[i];
    if (x[i]==0) {
      k--;
    }
  }
  int ans=1e9;
  int l=0,r=k-1;
  
  while (r<n) {
    if (x[r+1]<0) {
      l++;
      r++;
      continue;
    }
    if (l-1>=0&&x[l-1]>0) {
      l++;
      r++;
      continue;
    }
    if (x[l]>0) ans=min(ans,x[r]);
    else if (x[r]<0) ans=min(ans,-x[l]);
    else ans=min(ans,-x[l]+x[r]+min(-x[l],x[r]));
    l++;
    r++;
  }
  cout<<ans<<endl;     
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
	int s;
	cin >> s;
	int a = s / 100;
	int b = s - a * 100;
	if ((a > 12 && b > 12) || (a == 0 && b == 0) || (a == 0 && b > 12) || (a > 12 && b == 0))cout << "NA";
	if ((a > 12 || a == 0) && b > 0 && b <= 12)cout << "YYMM";
	if ((b > 12 || b == 0) && a > 0 && a <= 12)cout << "MMYY";
	if (a > 0 && a <= 12 && b > 0 && b <= 12)cout << "AMBIGUOUS";
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int cnt = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 != 0)
                {
                    cnt++;
                }
                else
                {
                    i = i * 10 - 1;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007

long long GCD(long long A,long long B)
{
    return (B == 0) ? A : GCD(B , A % B);
}


long long LCM(long long a,long long b)
{
    return a / GCD(a,b) * b;
}

void solve()
{

    int N;
    cin >> N;
    long long lcm = 1;
    for(int i = 0;i < N;i++)
    {
        long long tmp;
        cin >> tmp;
        lcm = LCM(lcm,tmp);
    }
    cout << lcm << '\n';
}

int main()
{
    solve();
}

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

using namespace std;

#define show(x) cerr << #x << " = " << x << endl;




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

   int num5 = 0, num7 = 0;

   if(a==5){
     num5++;
   }
   if(a==7)
   {
      num7++;
   }

   if(b==5){
     num5++;
   }
   if(b==7)
   {
      num7++;
   }

   if(c==5){
     num5++;
   }
   if(c==7)
   {
      num7++;
   }

   if(num5==2 && num7==1)
   {
     cout<<"YES"<<endl;
   }
   else
   {
     cout<<"NO"<<endl;
   }





  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e5+10;
ll dp[110][N];
ll w[N],val[N];
int main()
{ cool;
	ll n,W;
	cin>>n>>W;
	for(int i=1;i<=n;i++)
	  cin>>w[i]>>val[i];

   for(int j=0;j<=W;j++)
   	 { for(int i=1;i<=n;i++)
   	 	 { if(w[i]>j)
   	 	 	  dp[i][j]=dp[i-1][j];
   	 	 	 

   	 	 	else 
   	 	 	  { dp[i][j]=max( { dp[i-1][j] , val[i]+dp[i-1][j-w[i]] });
   	 	 	    //cout<<dp[i][j]<< " ";
   	 	 	  }  
   	 	 	  
   	 	 }
   	 	 //cout<<endl;
   	 }



  	 /*for(int i=0;i<=n;i++)
  	 { for(int j=1;i<=W;j++)
  	 	  cout<<dp[i][j]<<" ";
  	 	  cout<<endl;
  	 }*/
  	 cout<<dp[n][W];
  	 return 0;
}




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

struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
	   return a<x.a;
	}
} x[100005];

priority_queue<int> q;

int main()
{
	int n,m,i,j=1,s=0;
	cin>>n>>m;
	for(i=1;i<=n;++i)
	{
		 cin>>x[i].a>>x[i].b;
	}
	sort(x+1,x+n+1);
	for(i=1;i<=m;++i)
	{
		for(;x[j].a==i&&j<=n;++j)
		{
			q.push(x[j].b);
		} 
		if(!q.empty())
		{
		   s += q.top();
		   q.pop();
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1660
/**
*   @Author : MeGaCrazy
*   @InitTime : Wed Jan 02 20:43:20 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
  long long a,b;
  cin>>a>>b;

  long long ans=min(a,b/2);
  b=max(0ll,b-(a*2));
  cout<<ans+(b/4)<<endl;




}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

S = LI2()
K = I()

for i in range(K):
    if S[i] != 1:
        print(S[i])
        exit()
    elif i == K-1 and S[i] == 1:
        print(1)
        exit()


Measured memory_bytes: 62072
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll h, n;
	cin >> h >> n;
	vll a(n), b(n);
	for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];

	vll dp(h + 1, inf);
	dp[0] = 0;
	for (ll i = 1; i <= h; i++) {
		for (ll j = 0; j < n; j++) {
			dp[i] = min(dp[i], dp[max(0ll, i - a[j])] + b[j]);
		}
	}
	cout << dp[h] << endl;
}


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

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

    if(t % 1000 == 0)
        cout << 0;
    else
    {
        int k = t / 1000;
        cout << (k + 1) * 1000 - t;
    }
}


Measured memory_bytes: 3648
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, m] <- readInts
  ass <- sortOn last <$> replicateM m readInts
  print $ solve 0 ass

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> [[Int]] -> Int
solve _ [] = 0
solve p ([a, b]:ass)
  | a >= p
    = 1 + solve b ass
  | a < p
    = solve p ass


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

int main(void){
    int k,s,ans=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-i-j>=0 && s-i-j<=k) ans++;
        }
    }
    cout<<ans<<endl;

}

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

int main() {
  int N,M,cnt;
  cnt = 0;
  cin >> N;
  vector<int> T(N+1);
  for(int i=0;i<N;++i){
    cin >> T[i];
  }
  cin >> M;
  vector<int> P(M+1),X(M+1);
  for(int j=0;j<M;j++){
    cin >> P[j] >> X[j];
  }

  
  for(int l=0;l<M;l++){
    for(int k=0;k<N;k++){
      if(k!=(P[l]-1)){
        cnt += T[k];
      }else{
        cnt += X[l];
      }
    }
    cout << cnt << endl;
    cnt = 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
map<string,int> s;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        string now;
        cin>>now;
        s[now]++;
    }
    int mx=0;
    for(map<string,int>::iterator it=s.begin();it!=s.end();it++)
        mx=max(mx,it->se);
    for(map<string,int>::iterator it=s.begin();it!=s.end();it++)
        if(it->se==mx)
            cout<<it->fi<<endl;
    return 0;
}

Measured memory_bytes: 26496
import itertools

n, m = map(int, input().split())

path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

# 頂点を並び替える順列を生成してループ
for i in itertools.permutations(range(n), n):
    # 頂点1が始点
    if i[0] == 0:
        # 生成した順列の中をさらにループ
        for j in range(n):
            # n - 1 まで続いたら条件を満たすパスが存在する
            if j == n - 1:
                ans += 1
                break
            # i[j] から i[j + 1] に行くパスがなければ終了
            if not path[i[j]][i[j + 1]]:
                break

print(ans)

Measured memory_bytes: 40432
import sys
input = sys.stdin.readline
 
def main():
    N, M = map(int, input().split())
 
    ac_check = [False] * N
    p_counts = [0] * N
 
    for i in range(M):
        p, s = input().strip().split()
        p = int(p) - 1
        if s == "AC":
            if not ac_check[p]:
                ac_check[p] = True
        else:
            if not ac_check[p]:# まだ正解していないならペナルティ追加
                p_counts[p] += 1
 
    ac_count = 0
    p_count = 0
    for i in range(N):
        if ac_check[i]:# 正解している問題のみ考慮
            ac_count += 1
            p_count += p_counts[i]
    print(ac_count, p_count)
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[11],f[11],i=0;
	cin>>f;
	for(int j=0;f[j]!=0;j++){
		if(f[j]=='1'){
			a[i]='1';
			i++;
		}else if(f[j]=='0'){
			a[i]='0';
			i++;
		}else{
			i=max(0,i-1);
			a[i]=0;
		}
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
a, b, x = gets.chomp.split.map(&:to_i)

z = (a**2)*b # 容器の体積

if z / 2.0 <= x # x が半分以上
  n = z - x
  t = (2.0 * n)/(a**2)
  p (Math.atan(t/a) * 180 / Math::PI)
  exit
else
  t = (2.0 * x)/(a * b)
  p (Math.atan(b/t) * 180 / Math::PI)
end


Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


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

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

    int a,b,c;
    cin >> a >> b >> c;

    if ((a == b and a != c) or (a == c and a != b) or (b == c and b != a)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	
	string s;
	cin >> s;
	bool N = false;
	bool W = false;
	bool E = false;
	bool S = false;
	rep(i,s.size()){
		if(s[i] == 'N') N = true;
		else if(s[i] == 'W') W = true;
		else if(s[i] =='S') S = true;
		else E = true;
	}
	if(N == S && W == E )coY();
	else coN();
}


Measured memory_bytes: 256
import sys
from collections import deque

n = int(sys.stdin.readline())

inputs = []

for i in range(n):
    inputs.append(sys.stdin.readline().split())

linked_list = deque([])

for line in inputs:
    cmd = line[0]

    if len(line) == 2:
        value = line[1]

    if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop()

print(*linked_list)

Measured memory_bytes: 557404
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    if(N == 25){
        cout<<"Christmas"<<endl;
    }else if(N == 24){
        cout<<"Christmas Eve"<<endl;
    }else if(N == 23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(N == 22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }


    return 0;
}


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


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

    int l[N];
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    //昇順ソート
    sort(l, l + N, greater<int>());
    
    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += l[i];
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

int main(){
	FASTIO;
	string s, t; cin >> s >> t;
	ll n = s.length();
	ll m = t.length();
	ll ans = m;
	for ( int k = 0; k + m <= n; k++ ){
		ll temp = 0;
		for ( int j = 0; j < m; j++ ){
			if (t[j] != s[k + j])
				temp++;
		}
		ans = min(ans, temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long int
#define MOD 1000000007

void Fast_IO(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	freopen("debug.out","w",stderr);
	#endif
}

int main(){
	Fast_IO();
	int n,i,x;
	cin>>n;
	int a[n],ans[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	x=a[0];
	for(i=1;i<n;i++)
		x=x^a[i];
	for(i=0;i<n;i++)
		ans[i]=x^a[i];
	for(i=0;i<n;i++)
		cout<<ans[i]<<' ';
	cout<<'\n';
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int counter = 0;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == 'o') ++counter;
	}
	cout << 700 + counter * 100;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=i;
  }
  sum+=n*l;
  if(l>0 && n>0){
    sum-=l;
  }
  else if(l<0 && n-1+l<0){
    sum-=l;
    sum-=n-1;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256