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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = INT_MAX;
const ll linf = 3e18;
const double eps = 1e-9;

struct SegTree { // ??????min,max
    int n;
    vector<int> Max;
    vector<int> Min;
    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        Min.resize(2 * n);
        //Max.resize(2 * n);
        for (int i = 0; i < 2 * n - 1; ++i) {
            Min[i] = inf;
            //Max[i] = -inf;
        }
    }
    void update(int idx, int val) {
        idx += n - 1;
        Min[idx] = val;
        //Max[idx] = val;
        while (idx > 0) {
            idx = (idx - 1) / 2;
            Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
            //Max[idx] = max(Max[idx * 2 + 1], Max[idx * 2 + 2]);
        }
    }
    int get_min(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)???min
        if (r == -1) r = n;
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return Min[k];
        int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
    int get_max(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)???max
        if (r == -1) r = n;
        if (r <= a || b <= l) return -inf;
        if (a <= l && r <= b) return Max[k];
        int vl = get_max(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = get_max(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    }
};

signed main()
{
    int n, q; cin >> n >> q;

    SegTree seg;

    seg.init(n);

    rep(i, q) {
        int type, x, y;
        cin >> type >> x >> y;

        if (type % 2 == 0) {
            seg.update(x, y);
        } else {
            cout << seg.get_min(x, y + 1) << endl;
        }
    }
}

Measured memory_bytes: 2060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
    ll x=0,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;
}
ll n,x,ans;
int main(){
    n = read();
        x = n/11;
        ans = x*2+1;
        x = n % 11;
        if (x==0) ans--;
        if (x>6) ans++;
    printf("%lld",ans);
    return 0;
}

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

using namespace std;
#define lli long long int
#define rep(i, n) for(in i = 0; i < (int)n; i++)

int main()
{
    lli X;
    scanf("%lld", &X);

    lli start = 100;
    int ans = 0;
    while(1) {
        start += start * 0.01;
        ans++;

        if (start >= X)
            break;

    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3816
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

void solve() {
    set<string>s;
    string ss;
    ll n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> ss;
        s.insert(ss);
    }
    cout << s.size();
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}// smf

Measured memory_bytes: 19272
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int rate = scan.nextInt();
		if(rate < 1200){
			System.out.print("ABC");
		}
		else{
			System.out.print("ARC");
		}

	}

}

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

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}


string S;
int N;

bool check(string s){
    if((s.size()&1)==0||s.size()<3||s.substr(s.size()/2-1,3)!="iwi")return false;
    rep(i,s.size()/2){
        char l=s[i],r=s[s.size()-i-1];
        if(isalpha(l)){
            if(l!=r)return false;
        }
        else{
            if(l=='['&&r==']')continue;
            if(l==']'&&r=='[')continue;
            if(l=='('&&r==')')continue;
            if(l==')'&&r=='(')continue;
            if(l=='{'&&r=='}')continue;
            if(l=='}'&&r=='{')continue;
            return false;
        }
    }
    return true;
}

int main(){
    cin>>S;
    N=S.size();

    int ma=0;

    rep(i,1<<N){
        string sub;
        rep(j,N)if(i>>j&1)sub+=S[j];
        if(check(sub))chmax(ma,sub.size());
    }

    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
int main(){
	long long res=0,a,b,x;
	cin>>a>>b>>x;
	res=b;
	b=a;
	a=res;
	if(x==1){
		cout<<a-b+1;
		return 0;
	}
//	cout<<a<<b;
	res=0;
	if(b%x!=0){
		b=b+x-(b%x);
	}
	if(a%x!=0){
		a=a-(a%x);
	}
	res=(a-b)/x+1;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n, a; cin >> n >> a;
    for (int i = 0; i <= a; i++) {
        if ((n-i)%500 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define llt long long int

int main(){
	llt n,m,ans=0;
	string s1,s2="";
	cin>>n>>m;
	llt count=0;
	while(n--){
		llt x,y;
		cin>>x>>y;
		if(pow(x,2)+pow(y,2)<=pow(m,2))
		count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){

    int H, W;
    int x = 0;
    int y = 0;

    cin >> H >> W;

    while(H != 0 && W != 0){
        while(y != H){
            while(x != W){
                cout << '#';
                x++;
            }
            cout << endl;
            x = 0;
            y++;
        }
        cout << endl;
        cin >> H >> W;
        x = 0;
        y = 0;
    }

    return 0;
}


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

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

  int c[N]; 
  rep(i,N){
    c[i]=0;
  }
  int M = sqrt(N);
  rep(i,M) {
    int x = i + 1;
    int xx = x*x;
    if (xx > N) break;
    rep(j,M){
      int y = j + 1;
      int yy = y*y;
      int xy = x*y;
      if (xx + yy + xy > N) break; 
      rep(k,M){
        int z = k + 1;
        int n = xx + yy + z*z + xy + y*z + z*x;
        if (n > n) break;
        rep(l,N){
          if (l+1==n) c[l]++;
        }
      }
    }
  }
  rep(i,N){
    cout << c[i] << endl;
  }
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    vector<double> A(3);
    REP(i, 3) cin >> A[i];
    sort(A.begin(), A.end());
    cout << (A[0] * A[1] / 2.0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,A,B; cin>>N>>A>>B;
    string S; cin>>S;
    int ansA=0; int ansB=0;
    for(int i=0; i<N; i++){
       if(S.at(i)=='a'&&ansA<A+B){
            cout<<"Yes"<<endl;
            ansA++;
        }
        else if(S[i]=='b'&&ansA<A+B&&ansB<B){
            cout<<"Yes"<<endl;
            ansA ++;
            ansB ++;
        }
        else cout<<"No"<<endl;
    }
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int gcd(int a, int b) {
  if (b > 0) {
    return gcd(b, a % b);
  } else {
    return a;
  }
}

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

  ll A, B;
  cin >> A >> B;

  ll g = gcd(A, B);
  ll ans = A / g * B;

  cout << ans << endl;

  return 0;
}


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

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int g = min(min(a, b), min(c, d)), h = min(f, e);
    int sum = a + b + c + d + e + f;
    cout << sum - g - h << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int a; cin >> a;
	int count = 0;
	rep1(i, a) {
		if (i >= 1 && i <= 9)count++;
		else if (i >= 100 && i <= 999)count++;
		else if (i >= 10000 && i <= 99999)count++;

	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
  n, w = [int(e) for e in input().split()]
  t = [-1 for i in range(w + 1)]
  t[w] = 0
  for _ in range(n):
    nw, nv = [int(e) for e in input().split()]
    for i in range(nw, w + 1):
      if t[i] == -1:
        continue
      if t[i - nw] < t[i] + nv:
        t[i - nw] = t[i] + nv
  print(max(t))
main()

Measured memory_bytes: 44784
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<=b;i++) if((i-a<k)or(b-i<k)) cout<<i<<endl;
    rt0;
}

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >>k;
  if((e-a)>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

  int x,a,b;
    cin>>x>>a>>b;
    
    if(-a+b<=0)
       cout<<"delicious";
       
     else if(-a+b<=x)
           cout<<"safe";
        else
           cout<<"dangerous";
    

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define all(a) a.begin(),a.end()
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){x=x>y?y:x;}
template<class T> inline void gmax(T &x,const T &y){x=x<y?y:x;}
template<class T> inline bool Gmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T> inline bool Gmax(T &x,const T &y){return x<y?x=y,1:0;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m;
char s[N],t[N];

int main(){
#ifdef rqgao2014
	assert(freopen("input.txt","r",stdin));
#endif
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	scanf("%s",t);
	int d=__gcd(n,m);
	n/=d;m/=d;
	for(int i=0;i<d;i++)
		if(s[i*n]!=t[i*m]){puts("-1");return 0;}
	printf("%lld\n",(ll)n*m*d);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long double ld;
ld x[110],y[110],ans = 0;
vector<pair<ld,pair<ld,ld>>> p;
ld pi = 3.1415926535;
int main(){
	cout.precision(30);
	int i,j,k,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i] >> y[i];
			p.push_back({atan2(x[i],y[i]),{x[i],y[i]}});
	}
	sort(p.begin(),p.end());
	for(i=0;i<n;i++){
		for(j=i;j<i + n;j++){
			ld xx = 0,yy = 0;
			for(k=i;k<=j;k++){
				xx += p[k%n].second.first;
				yy += p[k%n].second.second;
			}
			ans = max(ans,xx*xx + yy*yy);
		}
	}
	cout << sqrt(ans) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)



int main(void) {
    string s;
    cin >> s;
    puts((s.find("AC")!=-1)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter


class BIT:
    """一点加算、区間取得クエリをそれぞれO(logN)で答えるデータ構造"""
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def build(self, array):
        """arrayを初期値とするBinaryIndexTreeを構築する O(N)"""
        for i in range(self.size):
            self.bit[i + 1] = array[i]
        for i in range(1, self.size):
            if i + (i & -i) > self.size:
                continue
            self.bit[i + (i & -i)] += self.bit[i]

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目の要素にvalを加える"""
        i += 1
        while i <= self.size:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)


n, q = map(int, input().split())
c = list(map(int, input().split()))
query = [list(map(int, input().split())) + [i] for i in range(q)]


bit = BIT(n)
memo = {}
ans = [0] * q
query = sorted(query, key=itemgetter(1))
ind = 0

for l, r, i in query:
    while ind < r:
        if c[ind] in memo:
            old_ind = memo[c[ind]]
        else:
            old_ind = -1
        memo[c[ind]] = ind
        bit.add(ind, 1)
        if old_ind != -1:
            bit.add(old_ind, -1)
        ind += 1
    ans[i] = bit.get_sum(l - 1, r)

print("\n".join(map(str, ans)))

Measured memory_bytes: 263984
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string s,t;
  cin >> s >> t;
  int sum = 0;
  for(int i = 0 ; i < 3 ; i++){
    if(s.at(i) == t.at(i)){
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (((N > 500) && (N % 500) <= A) || ((N < 500) && (A >= N))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,q; cin>>n>>q;
    string s; cin>>s;
    char t[q],d[q]; rep(i,q) cin>>t[i]>>d[i];
    int ans=n;
    int ok=-1,ng=n;
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        int tmp=mid;
        rep(i,q){
            if(tmp<0) break;
            if(s[tmp]==t[i]){
                if(d[i]=='L') tmp--;
                else tmp++;
            }
        }
        if(tmp<0) ok=mid;
        else ng=mid;
    }
    // cout<<ok<<endl;
    ans-=ok+1;
    ok=n,ng=-1;
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        int tmp=mid;
        rep(i,q){
            if(tmp>=n) break;
            if(s[tmp]==t[i]){
                if(d[i]=='L') tmp--;
                else tmp++;
            }
        }
        if(tmp>=n) ok=mid;
        else ng=mid;
    }
    // cout<<ok<<endl;
    ans-=n-ok;
    cout<<ans<<endl;
    return 0;
}


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

const ll mod = 1000000007;

// 2^t
ll pow(ll t) {
  if (!t) return 1LL;
  ll a = pow(t>>1);
  a *= a;
  a %= mod;
  if(t&1) a *= 2LL;
  return a % mod;
}

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


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

  ll zz = 0;

  map<pair<ll, ll>, ll> mem;
  set<pair<ll, ll>> MM;

  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;

    if (a == 0 && b == 0) zz++;
    else if (a == 0) mem[make_pair(0, 1)]++;
    else if (b == 0) mem[make_pair(1, 0)]++;
    else {
      bool neg = false;
      if ((a < 0 && b > 0) || (a > 0 && b < 0)) {
        neg = true;
      }
      a = abs(a);
      b = abs(b);
      ll g = gcd(a, b);
      if (neg) mem[make_pair(a / g, - b / g)]++;
      else mem[make_pair(a / g, b / g)]++;
    }
  }


  ll ans = 1LL;
  ll cnt = zz;
  for (auto x: mem) {
    ll a, b;
    tie(a, b) = x.first;
    if (b > 0LL) {
      if (mem.count(make_pair(b, -a))) {
        ll i = x.second, j = mem[make_pair(b, -a)];
        ans *= (pow(i) + pow(j) - 1LL + mod) % mod;
        ans %= mod;
        cnt += i + j;
      }
    }
  }

  ans *= pow(n - cnt);
  ans = (ans % mod + zz - 1LL + mod) % mod;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16028
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = input()

    # 二個以上連続で岩があったら無理
    for i in range(A + 1, max(C, D)):
        if S[i] == S[i + 1] == "#":
            print("No")
            return

    # 追い抜かす必要がない
    if C < D:
        print("Yes")
        return
    else:
        # 追い抜かす必要がある
        # 3つ以上連続で岩が置かれていない区間があれば良い
        for i in range(B - 1, D):
            if S[i] == S[i + 1] == S[i + 2] == ".":
                print("Yes")
                return

        print("No")
        return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
MOD = 10 ** 9 + 7
h, w = map(int, input().split())
dp = [[0 for i in range(w + 1)]for j in range(h + 1)]
a = [input()for _ in range(h)]
for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      dp[i + 1][j + 1] = 0
    elif i == j == 0:
      dp[i + 1][j + 1] = 1
    else:
      dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % MOD
print(dp[h][w])

Measured memory_bytes: 44628
import java.io.*;
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }
 
    static class Task {
 
        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int n = scan.nextInt(), k = scan.nextInt();
            long[] a = new long[n];
            long s = 0;
            for(int i = 0; i < n; i++) a[i] = scan.nextLong();
            shuffle(a);
            Arrays.sort(a);
            for(int j = 0; j < n - k; j ++) s += a[j];
            out.println(s);
        }
    }
 
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

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

    sort(v.begin(), v.end());

    for (string s : v) {
        cout << s;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
poll = {}
m = 0
for i in range(n):
    word = input()
    if word in poll:
        poll[word] += 1
    else:
        poll[word] = 1
    
    if poll[word] > m:
        m = poll[word]

words = [k for k, v in poll.items() if v == m]
words = sorted(words)
for word in words:
    print(word)

Measured memory_bytes: 32984
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        if (n % 2 == 0) {
            System.out.println(n / 2);
        } else {
            System.out.println(n / 2 + 1);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,min=1000000;
    cin>>n;
    vector<int> x(n);
    rep(i,n){
        cin>>x[i];
    }
    sort(ALL(x));
    for(int j=x[0];j<=x[n-1];j++){
        int total=0;
        rep(i,n){
            total += pow(abs(x[i]-j), 2);
        }
        if(total <= min) min = total;
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define minf 0x80000000
using namespace std;
int n,k,r,s,p;
string t;

void add(vector<int>&v,int i){
	if(t.at(i)=='r')v.at(i)=p;
	else if(t.at(i)=='s')v.at(i)=r;
	else v.at(i)=s;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	cin>>n>>k>>r>>s>>p;
	cin>>t;
	vector<int>v(t.size(),minf);
	for(int i=0;i<v.size();++i){
		if(v.at(i)==minf){
			add(v,i);
			for(int j=i+k;j<v.size();j+=k){
				if(t.at(j)==t.at(j-k)&&v.at(j-k)!=0)v.at(j)=0;
				else add(v,j);
			}
		}
	}
	cout<<accumulate(v.begin(),v.end(),0)<<"\n"s;
}

Measured memory_bytes: 848
import numpy

N=int(input())
str1=input().split(' ')
A=[0]*N
for i in range(N):
	A[i]=int(str1[i])

order=[0]*N
for i in range(1,N+1):
	idx=0
	idx=A[i-1]
	order[idx-1]=i

result=""
for i in range(N):
	result+=(str(order[i])+" ")

print(result)

Measured memory_bytes: 28520
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
 
const int MAX = 2000010;
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int arr[100010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N; cin >> N;

  vector<ll> A(N);
  REP(i,N) cin >> A[i];

  ll ans = 1;
  for(int i=0; i<N; i++){
    if(A[i] == 0){
      ans *= (3-arr[A[i]]);
    }else{
      ans *= arr[A[i]-1] - arr[A[i]];
    }
    arr[A[i]]++;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4428
function Main(s){
  s = s.split("\n");
  var n = +s[0];
  s = s[1].split(" ").map(a=>+a);
  s = s.reduce((a,b)=>a+b);
  console.log(s-n);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7500
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int gcd3(int A, int B) {
	if (B == 0) return A;
	else return gcd3(B, A % B);
}
ll gcd2(ll A, ll B) {
	if (B == 0) return A;
	ll k = A - ll(double(A) / B) * B;
	if (B < 2e9) return gcd3(B, k);
	else return gcd2(B, k);
}
ll gcd(ll A, ll B) {
	if (B == 0) return A;
	if (B < 2e9) return gcd3(B, A % B);
	if (B < 2e15) return gcd2(B, A % B);
	else return gcd(B, A % B);
}

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


	int N;
	cin >> N;
	pair<ll, ll> AB[200001];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = N - 1;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		ll G = gcd(abs(a), abs(b));
		a /= G;
		b /= G;
		if (a < 0) {
			a = -a;
			b = -b;
		}
		if (b > 0) AB[ka++] = { a,b };
		else AB[kb--] = { -b,a };
	}
	auto BA = AB + kb + 1;
	kb = N - 1 - kb;
	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = { 2e18, 2e18 };

	pair<ll, ll> mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		if (mae != AB[i]) {
			int tmp = 0;

			pair<ll, ll> mae2 = BA[p];
			int kB = 0;
			while (p < kb && BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	pair<ll, ll> mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 6776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

struct e
{
    int to;
    int cost;
};

int res[112345];

vector<e> g[112345];

void dfs(int p)
{
    for (auto i : g[p])
    {
        if (res[i.to] != -1)
            continue;

        if (i.cost % 2)
        {
            res[i.to] = 1 - res[p];
            dfs(i.to);
        }
        else
        {
            res[i.to] = res[p];
            dfs(i.to);
        }
    }
}

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

    int n;
    cin >> n;
    REP(i, n - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;

        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }

    memset(res, -1, sizeof(res));

    res[1] = 0;
    dfs(1);

    REP(i, n)
    cout << res[i + 1] << endl;

    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}},dy[7]={0,1,1,0,-1,-1,0};
typedef pair<int,int> P;

int d[2][444][444];
int a[444][444];

void Main() {
  int sx,sy,tx,ty;
  cin >> sy >> sx >> ty >> tx;
  int k;
  cin >> k;
  rep(i,k) {
    int x,y;
    cin >> y >> x;
    a[200+x][200+y]=1;
  }
  int n,m,ans=MAX;
  cin >> m >> n;
  rep(k,2)rep(i,444)rep(j,444) d[k][i][j]=MAX;
  d[0][200+sx][200+sy]=0;
  rep(t,2500) {
    rep(xx,400)rep(yy,400) {
      if(d[0][xx][yy]==MAX) continue;
      if(xx==200+tx&&yy==200+ty) ans=min(ans,d[0][xx][yy]);
      int c=abs((200-xx)*(200-yy)*t)%6;
      rep(i,7) {
        int x=xx+dx[yy%2][i],y=yy+dy[i];
        if(abs(x-200)>n||abs(y-200)>m||a[x][y]) continue;
        d[1][x][y]=min(d[1][x][y],d[0][xx][yy]+(c!=i));
      }
    }
    rep(i,400)rep(j,400) {
      d[0][i][j]=d[1][i][j];
      d[1][i][j]=MAX;
    }
  }
  if(ans==MAX) ans=-1;
  pr(ans);
}

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


Measured memory_bytes: 4912
from collections import deque
def bfs():
    d=[[float("inf")]*w for i in range(h)]
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    que=deque([])
    que.append((0,0))
    d[0][0]=0
    cnt=0
    while que:
        p=que.popleft()
        if p[0]==h-1 and p[1]==w-1:
            break
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx and nx<h and 0<=ny and ny<w and maze[nx][ny]!="#" and d[nx][ny]==float("inf"):
                que.append((nx,ny))
                d[nx][ny]=d[p[0]][p[1]]+1
    for i in range(h):
        for j in range(w):
            if maze[i][j]=="#":
                cnt+=1
    if d[h-1][w-1]!=float("inf"):
        return h*w-d[h-1][w-1]-1-cnt
    else:
        return -1

h,w=map(int,input().split())
maze=[list(input()) for i in range(h)]

print(bfs())

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vdewansa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        OMatching solver = new OMatching();
        solver.solve(1, in, out);
        out.close();
    }

    static class OMatching {
        final int MOD = 1_000_000_000 + 7;

        int add(int a, int b) {
            int res = a + b;
            if (res > MOD) res -= MOD;
            return res;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            boolean[][] a = new boolean[N][N];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    a[i][j] = (in.nextInt() != 0);
                }
            }
            int[] ways = new int[1 << N];
            ways[0] = 1;
            for (int s = 1; s < (1 << N); s++) {
                int i = Integer.bitCount(s) - 1;
                for (int j = 0; j < N; j++) {
                    if (((s >> j) & 1) != 0 && a[i][j]) {
                        int sPrev = s ^ (1 << j);
                        ways[s] = add(ways[s], ways[sPrev]);
                    }
                }
            }
            out.println(ways[(1 << N) - 1]);
        }

    }
}



Measured memory_bytes: 31060
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	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();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 3000 + 5;

int n;
int a[N];
vector<int> v[N];

int dfs(int x, int p) {
	for (int i = 0; i < (int)v[x].size(); i++) {
		int y = v[x][i];
		if (y == p) continue;
		if (a[x] > a[y] && !dfs(y, x)) return 1;
	}
	return 0;
}

int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1, x, y; i < n; i++) {
		read(x), read(y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for (int i = 1; i <= n; i++)
		if (dfs(i, 0)) printf("%d ", i); printf("\n");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  int n, i;
  int amount=100000, tmp;
  scanf("%d", &n);

  for(i=0;i<n;i++){
    amount *= 1.05;
    tmp = amount % 1000;
    if(tmp){
      amount = amount - tmp + 1000;
    }
  }
  printf("%d\n", amount);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i = x;i < y;i++)
using namespace std;
int main(){
  int N,mi=1000,ma=0,q;
  cin >> N;
  FOR(i,0,N){
    cin >> q;
    mi = min(q,mi);
    ma = max(q,ma);
  }
  cout << ma - mi << endl;
}


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

int main(){

  int i,j,change;
  int sumdata;
  int index;
  int *A;

  scanf("%d",&sumdata);

  A = malloc(sizeof(int) * (sumdata + 1));

  for(i = 0; i < sumdata; i++){

    scanf("%d",&A[i]);

  }

  i = 0;
  j = 0;
  index = A[sumdata - 1];

  while(j != sumdata-1){

    if(index >= A[j]){

      change = A[i];
      A[i] = A[j];
      A[j] = change;

      i = i + 1;
      j = j + 1;

    }

    else if(index < A[j]){

      j = j + 1;

    }


  }

  change = A[sumdata -1];
  A[sumdata -1] = A[i];
  A[i] = change;

  for( j = 0; j < i; j++){

    printf("%d ",A[j]);

  }

  printf("[%d] ",A[i]);

  for(j = i + 1; j < sumdata -1; j++){

    printf("%d ",A[j]);

  }

  printf("%d\n",A[sumdata -1]);

  return 0;

}

Measured memory_bytes: 992
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,j,a,b,c,d,n,k,x;
    cin>>x;
    c=0;
    n=100;
    for(;;){
        if(n>=x){
            break;
        }
        n=n+(n/100);
        c++;
    }
    cout<<c;
}

Measured memory_bytes: 3640
h,w=map(int,input().split())
s= [input() for _ in range(h)]
neighbor = [(-1,0),(0,-1),(1,0),(0,1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        else:
            flag = False
            for nei in neighbor:
                n = (i+nei[0],j+nei[1])
                if n[0]<0 or n[1]<0 or n[0]>=h or n[1]>=w:
                    continue
                if s[n[0]][n[1]] == '#':
                    flag = True
                    break
            if flag == False:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
S = input()
tmp = 0
check = False
for i in range(len(S)):
    for j in range(i, len(S)):
        for k in list(str(S[i:j + 1])):
            if k != "A" and k != "C" and k != "G" and k != "T":
                check = False
                #print(i, j, 100)
                break
            else:
                check = True
        if check:
            if j - i + 1 > tmp:
                #print(i, j)
                tmp = j - i + 1

print(tmp)

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

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> s;

    for(i=0;i<s.size();i++){
        if(s.at(i) == '9'){
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
 
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

n,x,y = i_l()
x -= 1
y -= 1
a = [0]*n

for i in range(n):
    for j in range(i+1, n):
        b = min(abs(i-j), abs(x-i)+1+abs(y-j), abs(y-j)+1+abs(y-i))
        a[b] += 1
        
for i in a[1:]:
    print(i)


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define ENDL "\n"

typedef long long int llint;

int main()
{
  int N;
  string S;
  int K;
  cin >> N >> S >> K;
  K--;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == S[K])
    {
      cout << S[i];
    }
    else
    {
      cout << "*";
    }
  }
  cout << ENDL;
  return 0;
}


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

using namespace std;

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

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

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

const int N = 2e3 + 10;
int64 dp[N][N];
ii a[N];

int n;
int64 solve(int L, int R) {
  if (L > R) return 0;
  int64& ret = dp[L][R];
  if (ret >= 0) return ret;
  int pos = L + n - 1 - R;
  ret = 1LL * abs(a[pos].second - L) * a[pos].first + solve(L + 1, R);
  ret = max(ret, 1LL * abs(a[pos].second - R) * a[pos].first + solve(L, R - 1));
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a, a + n, greater<ii>());
  memset(dp, 255, sizeof(dp));
  int64 ret = solve(0, n - 1);
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 35492
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        boolean flg = false;
        for (int i = 0; i <= Y / 10000; i++) {
            for (int j = 0; j <= Y / 5000; j++) {
                if (N - i - j < 0) {
                    break;
                }
                if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
                    System.out.println(i + " " + j + " " + (N - i - j));
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 21972