akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;

vector< PS > vs;
string s;
ll n;

int main(){
	while (cin >> s >> n){
		vs.push_back(PS(s, n));
	}
	sort(ALL(vs));
	s = "";
	REP(i, vs.size()){
		if (s != vs[i].first){
			cout << vs[i].first << endl;
			s = vs[i].first;
		}
		if (i == vs.size() - 1){
			cout << vs[i].second << endl;
			continue;
		}
		if (vs[i + 1].first != s){
			cout << vs[i].second << endl;
		}
		else{
			cout << vs[i].second << " ";
		}
	}
}

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


int main(){
  ll n;cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);

  vector<ll> dp(n,0);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1)-h.at(0));
  for(ll i=2;i<n;++i){
    ll v1 = abs(h.at(i)-h.at(i-2)) + dp.at(i-2);
    ll v2 = abs(h.at(i)-h.at(i-1)) + dp.at(i-1);
    dp.at(i) = min(v1,v2);
  }
  cout << dp.at(n-1) << endl;
  return 0;
}


Measured memory_bytes: 4756
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    immutable N = s_.to!int();
    auto ab = new long[2][N];
    foreach(ref v;ab) v = readln.split.map!(to!long).array();
    long c=0;
    foreach_reverse(ref v;ab) {
        immutable a=v[0], b=v[1];
        c+=(b-(a+c)%b)%b;
    }
    return c;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> F(N+1,0);
    for(ll i=1;i<=100;++i)
            for(ll j=1;j<=100;++j)
                for(ll k=1;k<=100;++k){
                    ll t=i*i+j*j+k*k+i*j+j*k+i*k;
                    if(i*i+j*j+k*k+i*j+j*k+i*k<=N)F[t]++;
                }
    for(ll i=1;i<=N;++i)prt(F[i]);fl

    return 0;
}



Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		input();
		solve();
	}

	static int h, w, n, k, f[][];

	private static void input(){
		h=s.nextInt();
		w=s.nextInt();
		n=s.nextInt();
		k=s.nextInt();
		f=new int[h][w];
	}

	private static void solve(){
		// loop:
		for(int i=0; i<h; i++){
			int rowsum=question(i,0,i,w-1);
			for(int j=0; j<w-1&&rowsum!=0; j+=2){
				int buf=question(i,j,i,j+1);
				rowsum-=buf;
				switch(buf){
				case 0:
					break;
				case 1:
					f[i][j]=question(i,j,i,j);
					f[i][j+1]=1-f[i][j];
					break;
				case 2:
					f[i][j]=1;
					f[i][j+1]=1;
					break;
				}
			}
			if(w%2==1) f[i][w-1]=rowsum;
		}

		long pow=1, result=0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				result+=f[i][j]*pow;
				result%=k;
				pow*=2;
				pow%=k;
			}
		}

		//Arrays.stream(f).map(Arrays::toString).forEach(System.out::println);

		answer(result);
	}

	private static final int question(int x1, int y1, int x2, int y2){
		System.out.printf("? %d %d %d %d\n",x1,y1,x2,y2);
		return s.nextInt();
	}

	private static final void answer(long a){
		System.out.printf("! %d\n",a);
	}
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[100100];

int main() {
    li n;
    cin >> n;
    rin{cin >> a[i];}
    li res = a[0] - 1;
    li ma = 1;
    a[0] = 1;
    repp(i, 1, n) {
        if (a[i] < ma + 1)continue;
        if (a[i] == ma + 1) {
            ma = ma + 1;
            continue;
        }
        res += (a[i] - 1) / (ma + 1);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define loop(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define rep(i, n) loop(i, 0, n)
#define rep1(i, n) loop(i, 1, n + 1)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl
int _ = (cin.tie(0), ios::sync_with_stdio(0), cout.precision(20), cout.setf(ios::fixed));

const int MOD = 1000000007;
int n, l;
int x[5010], a[5010];

int dp[5010][5010];

int main(){
    cin >> n >> l;
    rep(i, n) cin >> x[i], ++x[i];
    rep(i, n) cin >> a[i], a[i] ? 0 : a[i] = l;
    rep(i, l+1) dp[0][i] = 1;
    rep1(i, n){
        int a = ::a[i-1], x = ::x[i-1];
        loop(j, x, l+1){
            if((j-x)%a == 0) dp[i][j] += dp[i-1][j-1];
            if(j != x) dp[i][j] += dp[i][j-1];
            if(dp[i][j] > MOD) dp[i][j] -= MOD;
        }
    }
    cout << dp[n][l] % MOD << endl;
}

Measured memory_bytes: 69948
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A, V, B, W, T = sc.nextLong()
  val speedDiff = V - W
  val distance = math.abs(B - A)
  println(if (0 < speedDiff && distance <= speedDiff * T) "YES" else "NO")
}


Measured memory_bytes: 55364
MOD = 10**9+7
N = int(input())
x = list(map(int,input().split()))


kaijo = [1]
for i in range(1,N):
    kaijo.append(kaijo[-1]*i % MOD)

ans = 0
for i in range(N - 1):
    ans = (ans * (i+1) + (x[-1] - x[i]) * kaijo[i]) % MOD

print(ans)

Measured memory_bytes: 14352
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
wv.sort()
cost=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(w+1):
        if wv[i-1][0] <= j:
            cost[i][j]=max(wv[i-1][1]+cost[i-1][j-wv[i-1][0]],cost[i-1][j])
        else:
            cost[i][j]=cost[i-1][j]
print(cost[n][w])


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



vector<int> divisor(int n){ //約数列挙
    vector <int> v;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            v.push_back(i);
            if(i!=n/i) v.push_back(n/i);
        }
    }
    return v;
}

vector<int> fac(int n){ //素因数分解
    vector<int> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            //res[i]++;
            n/=i;
            if(n%i!=0) res.push_back(i);
        }
    }
    return res;
}

signed main(){
    ll a,b;
    cin >>a >> b;
    vector<ll> v1;
    vector<ll> v2; 
    v1=divisor(a);
    v2=divisor(b);
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    vector<ll> s;
    set_intersection(v1.begin(),v1.end(),v2.begin(),v2.end(),back_inserter(s));


    vector<int> ans={};

    for(auto x:s){
        vector<int> v;
        v=fac(x);
        bool z=false;
        for(auto y:v){
            auto result = find(ans.begin(),ans.end(),y);
            if(result==ans.end()) continue;
            else{
                z=true;
                break;
            }
        }
        if(!z) ans.push_back(x);
    }

    cout << ans.size() << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 100
#define INF 1000
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n, graph[N][N], d[N];
 
void bfs(void){
    int i, v;
    int head, tail;
    int que[N*N], color[N];
  
    head = -1;
    tail = 1;

    for(i = 0; i < n; i++){
        d[i] = INF;
        color[i] = WHITE;
    }

    color[0] = GRAY;
    que[++head] = 0;
    d[0] = 0;
  
    while(head != tail){
        v = que[head++];
        for(i = 0; i < n; i++){
            if(graph[v][i] == 1 && color[i] == WHITE){
                color[i] = GRAY;
                que[tail++] = i;
                d[i] = d[v] + 1;
            }
        }
        color[v] = BLACK;
    }
}
void init(void){
    int i, j;
  
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            graph[i][j] = 0;
        }
    }
    return ;
}
void print(void){
    int i;
    for(i = 0; i < n; i++){
        printf("%d ", i + 1);
        if(d[i] == INF) printf("-1\n");
        else             printf("%d\n", d[i]);
    }
    return ;
}
 

int main(){
    int i, j, l, m, in;

    init();
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        
        scanf("%d%d", &l, &m);
        for(j = 0; j < m; j++){
            scanf("%d", &in);
            graph[l - 1][in - 1] = 1;
        }
    }
  
    bfs();
    print();
  
    return 0;
}

Measured memory_bytes: 640
from collections import deque

s = input()
q = int(input())
r = 1
top = deque()
top.append(s)
for _ in range(q):
    inp = input()
    if inp[0] == "1":
        r *= -1
    else:
        _, f, c = inp.split()
        if f == "1" and r == -1 or f == "2" and r == 1:
            top.append(c)
        else:
            top.appendleft(c)
ans = "".join(top)
print(ans if r == 1 else ans[::-1])


Measured memory_bytes: 6900
#include<bits/stdc++.h>
#define LL long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=1002;
LL S;

void read(LL &x){ scanf("%lld",&x); }

int main(){
	read(S);
	LL x=sqrt(S)+0.5,y=S/x;
	if (x*y<S) y++;
	LL v=x*y-S;
	LL a=x-1,b=y-v;
	printf("%lld %lld %lld %lld %lld %lld\n",a,0,0,b,x,y);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	while (H != 0 && W != 0) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << '#';
			}
			cout << endl;
		}

		cout << endl;
		cin >> H >> W;
		
	}

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int dp[3001][3001];
string s,t;

int solve(unsigned int i,unsigned int j){
	
	if( dp[i][j] != -1) return dp[i][j];
	
	if( i > s.length()-1 || j > t.length()-1) return 0;
	
	if(s[i] == t[j]) dp[i][j] = 1 + solve(i+1,j+1);
	else {
		
		dp[i][j] = max(solve(i,j+1),solve(i+1,j));
	}
	
	return dp[i][j];
}



int main(){

  
  cin >> s >> t;
  
  memset(dp,-1,sizeof(dp));
  
  solve(0,0);
  
  unsigned int i =0;
  unsigned int j =0;
  
  string ans ="";
  
  //cout << dp[s.length()][t.length()] <<endl;
  
  while( i<=s.length()-1 && j <= t.length()-1){
	  if(s[i] == t[j]) { 
		  ans+= s[i];
		  i++;
		  j++;
	  }
	  else if( dp[i+1][j] > dp[i][j+1]) i++;
	  else j++;
	  
  }
  
  cout << ans <<endl; 
	   
} 





Measured memory_bytes: 35712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public class A
{
  
    public static void Main(string[] args)
    {
        int t = 1;
        while (t > 0)
        {
            //var arr = Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
            var s = Console.ReadLine().Trim();
            var totalHugs = 0;
            for(int i = 0; i < s.Length / 2; i++)
            {
                if(s[i] != s[s.Length - i - 1])
                {
                    totalHugs++;
                }
            }
            Console.WriteLine(totalHugs);
            t--;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    int N; cin>>N;
    vector<lint> H(N);
    REP(i, N) cin>>H[i];
    int a = -1;
    int res = 0;
    REP(i, N){
        if(H[i]>=a){
            a = H[i];
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int N=100;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a[N][N];
	CLR(a);
	cin >> n;
	FOR(i,0,n){
		int k,l;
		cin >> k >> l;
		FOR(j,0,l){
			int m;
			cin >> m;
			++a[i][m-1];
		}
	}
	FOR(i,0,n){
		FOR(j,0,n){
			if(j!=0)cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;
int pos, p, q, r;
string str;

int term();
int factor();
int number();

int formula(){
    if (isdigit(str[pos])) {
        return str[pos++] - '0';
    }
    if (str[pos] == 'P') {
        pos++;
        return p;
    }
    if (str[pos] == 'Q') {
        pos++;
        return q;
    }
    if (str[pos] == 'R') {
        pos++;
        return r;
    }
    int res = 0;
    if (str[pos] == '-') {
        pos++;
        return 2 - formula();
    }
    if (str[pos] == '(') {
        pos++;
        res = formula();
        if (str[pos] == '*') {
            pos++;
            res = min(res, formula());
        }
        else if (str[pos] == '+') {
            pos++;
            res = max(res, formula());
        }
        pos++;
    }

    return res;
}

int main()
{
    while (true) {
        cin >> str;
        if (str == ".") {
            break;
        }
        int count = 0;
        for (p = 0; p <= 2; p++) {
            for (q = 0; q <= 2; q++) {
                for (r = 0; r <= 2; r++) {
                    pos = 0;
                    if (formula() == 2) {
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
using namespace std;

int main()
{
  int a, b;
  long long sum = 0;
  long long i = 2;

  cin >> a >> b;

  if(a % b == 0)
  {
    cout << -1 << endl;
    exit(0);
  }
  while(i < 1000000000000000000)
  {
    if(a * i % b != 0)
    {
      cout << a * i << endl;
      exit(0);
    }
    i++;
  }

}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 10;

int N, Nr[MAX_N], A;
int main() {
	cin >> N >> A;
	ll ans = 0;
	for(int i=0; i<N; i++) {
		scanf("%d", &Nr[i]);
		if(Nr[i] > A) ans += Nr[i] - A, Nr[i] = A;
	}
	for(int i=0; i<N-1; i++) {
		if(Nr[i] + Nr[i+1] > A) {
			int val = Nr[i] + Nr[i+1] - A;
			Nr[i+1] -= val;
			ans += val;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n;
char str[500005];

int t[500005];

int trial(int x){
	memset(t, 0, sizeof(t));
	x *= 9;
	t[0] = x;
	for(int i=0; i<n; i++){
		t[i] += 9 * (str[i] - '0');
	}
	for(int i=0; i<n || t[i]; i++){
		t[i+1] += t[i] / 10;
		t[i] %= 10;
		x -= t[i];
	}
	return x >= 0;
}

int main(){
	cin >> str;
	n = strlen(str);
	reverse(str, str + n);
	int s = 0, e = n;
	while(s != e){
		int m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m+1;
	}
	cout << s;
}


Measured memory_bytes: 2688
inp = [int(i) for i in input().split()]
if inp[0] % 2 == 0:
    if inp[1] <= inp[0]//2:
        print("YES")
    else:
        print("NO")
else:
    if inp[1] <= inp[0]//2 + 1:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
m, f, r = map(int, input().split())
while not (m+f+r == -3):
    if (m+f >= 80):
        print("A")
    elif (m+f >= 65):
        print("B")
    elif (m+f >= 50):
        print("C")
    elif (m+f >= 30):
        if (m==-1 or f==-1):
            print("F")
        elif (r >= 50):
            print("C")
        else:
            print("D")
    else:
        print("F")
    m, f, r = map(int, input().split())



Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
	int x;
	int i=0;
	int sum=0;
	cin>>x;
	while(sum<x)
	{
		i++;
		sum+=i;
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  rep(i, 5) {
    int in(a);
    if (a == 0) {
      cout << i+1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3620
use std::io;


/// https://beta.atcoder.jp/contests/abc071/tasks/abc071_b
fn main() {
    let s = read_one::<String>();
    let az = "abcdefghijklmnopqrstuvwxyz".to_string()
        .chars().collect::<Vec<char>>();

    for c in az {
        if !s.contains(&c.to_string()) { println!("{}", c); return; }
    }
    println!("None");
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>

int main()
{
    int x, y;
    for (int i = 0; i < 3000; i++) {
        std::cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        } else {
            if (x > y) {
                std::cout << y << ' ' << x << std::endl;
            } else {
                std::cout << x << ' ' << y << std::endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in x;
    cin>>x;
    in cnt500=x/500ll;
    x -=x/500ll*500ll;
    in cnt5=x/5ll;
    // cout<<cnt500*1000ll<<endl;
    cout<<cnt500*1000ll+cnt5*5ll<<endl;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int s = 0;
  while (m--) {
    int a;
    cin >> a;
    s += a;
  }
  if (s > n) {
    cout << "-1\n";
  } else {
    cout << n - s << '\n';
  }
}


Measured memory_bytes: 3656
#include <iostream> 
#include <sstream> // istringstream
#include <string> // 文字列
#include <algorithm> // アルゴリズム
#include <cmath> // 
#include <vector> // vector
#include <set> // set
#include <map> // map

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++) // for文の省略

int main()
{   
    // input sample
    long long N; 
    cin >> N;
    
    if (N % 1000 != 0) {
        cout << 1000 - (N % 1000) << endl;
    }
    else {
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int n,x,l;
    int d=0;
    int count=1,i;

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

    for (i=1;i<=n;i++)
    {
        scanf("%d",&l);
        d=d+l;
        if (d<=x)
        {
            count=count+1;
        }
    }
    printf("%d",count);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n;
  cin >> n;
  vi x(n);
  rep(i, n) cin >> x[i];

  int ans = 1e9;
  for (int p = 1; p < 101; p++)
  {
    int sum = 0;
    rep(i, n) sum += (x[i] - p) * (x[i] - p);
    chmin(ans, sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin>>n;
     vector<int> A(2);
A[2]=n/100;
  A[1]=n/10%10;
  A[0]=n%100%10;
for (int i = 0; i < 3; i++) {
 if(A[i]==1){
   A[i]=9;
 }
  else{
    A[i]=1;
  }
  
}
 
  cout<<A[2]<<A[1]<<A[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  rep(i,s.size()){
    cout << "x";
  }
  cout << endl;

  
  return 0;
    

}


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

const double PI=acos(-1.0);
const int N=200001;
const int MOD=1e9+7;

int a[N];
int main()
{
    int n;
    cin>>n;
    int mx = 0, mx2 = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        if(a[i] > mx)
            mx2 = mx, mx = a[i];
        else if(a[i] >= mx2)
            mx2 = a[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] == mx)
            cout<<mx2<<'\n';
        else
            cout<<mx<<'\n';
    }

}





Measured memory_bytes: 2432
//by rng_59
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 0;

int main(void) {
	long long N,a,b,ans = 0;
	cin >> N >> a >> b;
	ans += a;
	if(N < a+b) {
		if(N>=a) ans += a;
		else ans += N;
	}
	ans *= N/(a+b);
	N %= a+b;
	if(N>=a) ans += a;
	else ans += N;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 1000;
	ll stock = 0;
	for (int i = 0; i < N; i++) {
		if (stock == 0) {
			if (A[i] < A[i + 1]) {
				stock += ans / A[i];
				ans -= stock * A[i];
			}
		}
		else {
			if (A[i] > A[i + 1]) {
				ans += stock * A[i];
				stock = 0;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		System.out.println(((100 * in.nextInt() + 10 * in.nextInt() + in.nextInt()) % 4 == 0) ? "YES" : "NO");
	}
}


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

using namespace std;

typedef long long ll;

int main() {
	ll h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0)
		cout << 0 << endl;
	else {
		ll ans = 99999999;
		for (ll i = 1; i < h; i++) {
			ll t = max(i*w, (h - i)*(w / 2 + w % 2)) - min(i*w, (h - i)*(w / 2));
			ans = min(min(ans, t), min(h, w));
		}
		for (ll i = 1; i < w; i++) {
			ll t = max(i*h, (w - i)*(h / 2 + h % 2)) - min(i*h, (w - i)*(h / 2));
			ans = min(min(ans, t), min(h, w));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 100005


// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

 
    
   	int n;
   	cin >> n;

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

   	int pos[n+1] = {0}, dp[n+1] = {0};

   	//cout << a[4] << endl;
   	
   	pos[1] = a[1];
   	for(int i=2;i<=n;i++)
   		pos[i] = pos[i-2] + a[i];

   	for(int i=2;i<=n;i++)
   	{
   		if(i%2==1)
   			dp[i] = max(dp[i-1], dp[i-2] + a[i]);
   		else
   			dp[i] = max(pos[i-1], dp[i-2] + a[i]);
   		//cout << dp[i] << " " << pos[i] << endl;
   	}

   	cout << dp[n];

   	
    
    
    return 0;
 
} 

Measured memory_bytes: 8320
[w,h,n]=[int(i) for i in input().split()]
a=[]
for i in range(n):
    a.append([int(j) for j in input().split()])
#それぞれのマスを左下の座標で管理
#(0,0)から(w-1,h-1)まで
#print(a)
b=[]
for i in range(w):
    for j in range(h):
        b.append([i,j])
#print(b)
#全ての入力について、大小で外していく
for i in range(n):
    if a[i][2]==1:
        for j in range(w*h):
            if b[j][0]<a[i][0]:
                b[j]=[-10,-10]
    elif a[i][2]==2:
        for j in range(w*h):
            if b[j][0]>=a[i][0]:
                b[j]=[-10,-10]
    elif a[i][2]==3:
        for j in range(w*h):
            if b[j][1]<a[i][1]:
                b[j]=[-10,-10]
    elif a[i][2]==4:
        for j in range(w*h):
            if b[j][1]>=a[i][1]:
                b[j]=[-10,-10]
#print(b)
c=[i for i in b if i!=[-10,-10]]
#print(c)
print(len(c))

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

int main() {
int n;
cin>>n;
int s=0;
int tmp=n;
while(tmp>0){
  s += tmp%10;
  tmp /=10;
}
if(n%s==0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define N 105
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int ans;
char s[N];
char tmp[N];
int n;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	ans=n;
	memcpy(tmp,s,sizeof s);
	for(int i='a';i<='z';++i)
	{
		memcpy(s,tmp,sizeof tmp);
		bool ok=0;
		for(int j=1;j<=n;++j)
			if(s[j]==i)
				ok=1;
		if(!ok)continue;
		for(int len=n;;--len)
		{
			bool ok=1;
			for(int j=1;j<=len;++j)
				if(s[j]!=i)
					ok=0;
			if(ok)
			{
				ans=min(ans,n-len);
				break;
			}
			for(int j=2;j<=len;++j)
				if(s[j]==i)
					s[j-1]=i;
		}
	}
	printf("%d\n",ans);
}


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

#define NIL -1

using namespace std;

class NODE {
public:
	int key, p = NIL, right = NIL, left = NIL;
	NODE(int key) {
		this->key = key;
	}
};

vector<NODE> T;
int root = NIL;

void insert(int z) {
	int y = NIL, x = root;
	while (x != NIL) {
		y = x;
		if (T[z].key < T[x].key) x = T[x].left;
		else x = T[x].right;
	}
	T[z].p = y;
	if (y == NIL) { root = z; }
	else if (T[z].key < T[y].key) { T[y].left = z; }
	else T[y].right = z;
}

void In(int a) {
	if (a != NIL) {
		In(T[a].left);
		cout << " " << T[a].key;
		In(T[a].right);
	}
}

void Pre(int a) {
	if (a != NIL) {
		cout << " " << T[a].key;
		Pre(T[a].left);
		Pre(T[a].right);
	}
}


int main() {
	string cmd;
	int m, cnt = 0, key;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> key;
			NODE z(key);
			T.push_back(z);
			insert(cnt);
			cnt++;
		}

		else if (cmd == "print") {
			In(root); cout << endl;
			Pre(root); cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 11176
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d || (abs(b-a) <= d && abs(c-b) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,z,zs;
int main()
{
    cin>>a>>b;
    if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)z=1;
    if(a==4||a==6||a==9||a==11)z=2;
    if(a==2)z=3;
    if(b==1||b==3||b==5||b==7||b==8||b==10||b==12)zs=1;
    if(b==4||b==6||b==9||b==11)zs=2;
    if(b==2)zs=3;
    if(z==zs)cout<<"Yes";else
    cout<<"No";
    cout<<'\n';
    return 0;
}


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

int main(){
  int n, x= 1;//x�͔���p
  cin >> n;
  vector<int> a(n);

  for(int i=0; i<n ; ++i){
    cin >> a.at(i);
  }
  vector<int> b(n);
  copy(a.begin(),a.end(),b.begin());
  sort(b.begin(),b.end());
  int max  = b.at(n-1);
  int max2 = b.at(n-2);
  if(max == max2){ x = 0;}

  for(int i=0; i<n ; ++i){
    if(a.at(i) != max){
      cout << max << endl;
    }else{
      (x== 0)?(cout<< max <<endl):(cout<< max2 <<endl);
    }
  }

}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb      push_back
#define all(v)  v.begin(),v.end()
#define see(x)  cout<<#x<<" : "<<(x)<<endl;
#define ya      cout<<"YES"<<endl;
#define no      cout<<"NO"<<endl;
#define ff      first
#define sc      second
#define inf     999999999
typedef long long ll;
typedef pair<ll,ll> pii;

const int mod=1e9+7;

int main()
{

    ll n,i,ans=0;
    cin>>n;
    if(n==1)
    {
        cout<<0;
        exit(0);
    }
    ll a=1,b=1,c=1;
    
    for(i=1;i<=n;i++)
    {
        a=(a*10)%mod;
        c=(c*9)%mod;
        b=(b*8)%mod;
    }
    
    c=(c*2)%mod;
    
    cout<<((a-c+mod)%mod+b%mod+mod)%mod<<endl;

    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll d, n;
  cin >> d >> n;
  if(n == 100) n++;
  ll ans = n * pow(100, d);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           ll ans=0;
           ll mx=0;
           vin a(n);
           rep(i,0,n){
             cin>>a[i];
            if(a[i]>=mx){
             mx=a[i]; 
            }
             else{
              ans+=mx-a[i]; 
             }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
#define int long long


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,w;
	cin>>n>>w;
	pair<int,int> arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr+1,arr+n+1);
	int dp[n+1][w+1];
	for(int j=0;j<=w;j++)
	{
		if(j<arr[1].first)
			dp[1][j]=0;
		else
		{
			dp[1][j]=arr[1].second;
		}
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(j<arr[i].first)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],arr[i].second+dp[i-1][j-arr[i].first]);
			}
		}
	}
	cout<<dp[n][w]<<endl;
	
return 0;
}

Measured memory_bytes: 78336
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int[] sum = new int[N+1];
		for (int i=0;i<N;i++) {
			if (S.charAt(i)=='.') {
				sum[0]++;
			}
		}
		for (int i=1;i<N+1;i++) {
			if (S.charAt(i-1)=='#') {
				sum[i]=sum[i-1]+1;
			} else {
				sum[i]=sum[i-1]-1;
			}
		}
		Arrays.sort(sum);
		System.out.println(sum[0]);
	}
}

Measured memory_bytes: 27916
#include<bits/stdc++.h>
#define int long long 
using namespace std;

int32_t main()
{
	int h,a;
	cin>>h>>a;
	
	int sum=0;
	for (int i=0;i<a;i++){
		int u;
		cin>>u;
		sum+=u;
	}
	
	if (sum>=h)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	
	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define 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 put(a) cout<<a<<"\n"
#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;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> 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;}

int main(){
    int a,p;
    cin >> a >> p;
    put((a*3+p)/2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
using namespace std;
map<string,int> m;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.size();
	return 0;
 } 

Measured memory_bytes: 19236
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
} 

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $n, $m, $a);
while ($n!=0||$m!=0||$a!=0) { 
$array=[];
for ($i=0; $i < $m; $i++) { 
	fscanf(STDIN, "%d %d %d", $key, $x, $y);
	$array[$key][$x]=$y;
	$array[$key][$y]=$x;
}

$now = $a;
for ($i=1000; $i > 0; $i--) { 
	if (isset($array[$i][$now])) {
	    $now=$array[$i][$now];
	}
}
printf("%d\n", $now);

fscanf(STDIN, "%d %d %d", $n, $m, $a);
}




Measured memory_bytes: 9900
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    vector<int>in(a);
    rep(i,a)cin>>in[i];
    sort(all(in));
    vector<int>sa(a-1);
    rep(i,a-1)sa[i]=in[i+1]-in[i];
    sort(all(sa));
    int sum=0;
    rep(i,a-b)sum+=sa[i];
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1860
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N;
vector<pair<ll,ll>> vec;

void solve() {
	cin >> N;
	vec.resize(N);
	rep(i, N) {
		cin >> vec[i].first >> vec[i].second;
	}

	sort(vec.begin(), vec.end(), [](const pair<ll, ll>& x, const pair<ll, ll>& y) {
		return x.second < y.second;
	});

	bool ans = true;
	ll time = 0;
	rep(i, N) {
		if (time + vec[i].first <= vec[i].second) {
			time += vec[i].first;
		}
		else {
			ans = false;
			break;
		}
	}

	if (ans) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return;

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 3328
def main():
    from itertools import accumulate

    N = int(input())
    *A, = map(int, input().split())
    *acc, = accumulate(A)

    def count(w: int = 1) -> int:
        # m: -+-+-
        # w: +-+-+
        ret = 0
        add_val = 0
        for i, x in enumerate(acc):
            if (i & 1) ^ w:
                b = max(0, 1 - (x + add_val))
                ret += b
                add_val += b

            else:
                b = max(0, (x + add_val) - (-1))
                ret += b
                add_val -= b
        return ret

    ans = min(
        count(w=0),
        count(w=1)
    )

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14212
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	ll a, v, b, w,t;
	cin >> a >> v >> b >> w>>t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	ll renge = b - a;
	if (renge < 0)renge *= -1;
	rep(i, t) {
		renge -= (v-w);
		if (renge == 0) {
			cout << "YES" << endl;
			return 0;
		}
		else if (renge <= (v-w)) {
			i++;
			if (i < t) {
				cout << "YES" << endl;
				return 0;
			}
			else i--;
		}
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;s+="0";
  for(int i=0;i<s.size()-2;i++){
    if(s[i]==s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    if(s[i]==s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
  return 0;
}


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

int main()
{
	int n,W;
	cin >>n>>W;
	vector<vector<int> > v(n+1,vector<int>(2));
	for(int i=1;i<=n;i++)
	{
		cin>>v[i][0]>>v[i][1];
	}

	vector<vector<long long int> >dp(n+1 ,vector<long long int>(W+1,0));
	for(int i=0;i<=n;i++)
	{
		for(int w=0;w<=W;w++)
		{
			if(i==0 || w==0)
				dp[i][w]=0;
			else if(w >= v[i][0])
				dp[i][w] = max(dp[i-1][w],dp[i-1][w-v[i][0]]+v[i][1]);
			else
				dp[i][w] = dp[i-1][w];
		}
	}
	/*for (int i = 0; i <= n ; ++i)
	{
		for (int j = 0; j < W+1; ++j)
		{
			cout << dp[i][j] <<" ";
		}
		puts(" ");
	}*/
	cout << dp[n][W];
	return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&c <= b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int r, c;
    int mat[101][101] = {};

    scanf("%d %d", &r , &c);

    int rsum = 0;
    int csum = 0;
    int sum = 0;

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

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

    return 0;
}


Measured memory_bytes: 2100
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline ll read()
{
	ll out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
typedef pair<int,ll> node;
#define mp make_pair
//map<node,node> vis;
node calc(int x,ll cnt)
{
	if(cnt==1)
		return mp(x,0);
//	node tmp=mp(x,cnt);
//	if(vis.find(tmp)!=vis.end())
//		return vis[tmp];
	node res;
	if(cnt&1LL)
	{
		if(x<5)
		{
			res=calc(x<<1,cnt>>1LL);
			if(res.first+x>=10)
			{
				res.first+=x-9;
				res.second++;
			}
			else
				res.first+=x;
		//	return vis[tmp]=res;
			return res;
		}	
		else
		{
			res=calc(2*x-9,cnt>>1LL);
			res.second+=(cnt>>1LL);
			if(res.first+x>=10)
			{
				res.first+=x-9;
				res.second++;
			}
			else
				res.first+=x;
		//	return vis[tmp]=res;
			return res;
		}
	}
	else
	{
		if(x<5)
		//	return vis[tmp]=calc(x<<1,cnt>>1LL);
			return calc(x<<1,cnt>>1LL);
		else
		{
			res=calc(2*x-9,cnt>>1LL);
			res.second+=cnt>>1LL;
		//	return vis[tmp]=res;
			return res;
		}	
	}
}
int main()
{
	ll ans=-1;
	int m=read(),k=0;
	for(int i=1;i<=m;++i)
	{
		int x=read();
		ll cnt=read();
		ans+=cnt;
		node tmp=calc(x,cnt);
		ans+=tmp.second;
		if(tmp.first+k>=10)
			++ans,k+=tmp.first-9;
		else
			k+=tmp.first;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 764