akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define MOD (1000000007LL)

using namespace std;

int main(void){
    int A, B;
    cin >> A >> B;
    for(int i = 0; i <= 10000; i++){
        if((i * 8) / 100 == A && (i * 10) / 100 == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    int k,a,b;
    cin>>k>>a>>b;
    if(b/k - (a-1)/k > 0)
    {
        cout<<"OK";
    }
    else
    {
        cout<<"NG";
    }
    
    return 0;
}


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

const int N=200100,inf=1e9;
int n,mx,xm,mn=inf,nm=inf;
typedef long long ll;
ll ans;
pair<int,int>a[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i].first>>a[i].second;
		if(a[i].first>a[i].second)swap(a[i].first,a[i].second);
		mx=max(mx,a[i].second);mn=min(mn,a[i].second);
	}
	sort(a+1,a+n+1);
	ans=(ll)(a[n].first-a[1].first)*(mx-mn);
	for(int i=1;i<=n;++i){
		xm=max(xm,a[i].second);
		nm=min(nm,a[i].second);
		ans=min(ans,(ll)(max(xm,a[n].first)-min(nm,a[i+1].first))*(mx-a[1].first));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1920
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())

    N = int(input())
    As = list(map(int, input().split()))

    allprod = 1
    for A in As:
        allprod *= A

    total = 0
    for A in As:
        total += allprod / A

    print(allprod / total)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] p = new int[n];
        int sum = 0;
        for(int i=0;i<n;i++){
            p[i] = Integer.parseInt(sc.next());
            if(p[i]!=i+1){
                sum++;
            }
        }
        if(sum==2 || sum==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
        sc.close();
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  ll n;
  cin >> n;
  string s = "";
  while(n){
    n--;
    s += 'a'+n%26;
    n /= 26;
  }
  reverse(ALL(s));
  cout << s << endl;






  return 0;
}

Measured memory_bytes: 3628
str1 = gets.split
N,K = str1[0].to_i, str1[1].to_i

a = []
for x in 0...20
  a[x] = 0
end

if N-K+1 >= 0
  a[0] = N-K+1
else
  a[0] = 0
end

b = 2
c = 1
for x in 1...20
  if (K-1)/c == 0
    a[x] = 0
  elsif N >= (K-1)/c
    a[x] = (K-1)/c - ((K-1)/b+1) + 1
  else
    a[x] = N - ((K-1)/b+1) + 1
  end
  if a[x] < 0
    a[x] = 0
  end
  b = b*2
  c = c*2
end

answer = 0.0
d = 1.0

for x in 0...20
  answer += a[x]*d/(N*1.0)
  d = d*0.5
end

puts answer

Measured memory_bytes: 1788
N=int(input())

red = [list(map(int,input().split())) for i in range(N)]
blue = [list(map(int,input().split())) for i in range(N)]

red.sort(key=lambda x:x[1], reverse=True)
blue.sort(key=lambda x:(x[0]))

ans = 0

for bluex, bluey in blue:
    for redx, redy in red:
        if bluex>redx and bluey>redy:
#            del red[red.index([redx,redy])]
            red.remove([redx,redy])
            ans+=1
            break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r) { return l.second < r.second; }
bool greaterPair(const ipair& l, const ipair& r) { return l.second > r.second; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define irep(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rirep(i, n) for (int i = n; i >= 0; --i)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool pal(string s) {
	int n = s.length() / 2;
			rep(i, n) {
			if (s[i] != s[s.length() - 1 - i]) return false;
		}
			return true;
}

int euclidean_gcd(int a, int b) {
	if (a < b) return euclidean_gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

vector <string> vec_sort_and_del(vector<string> s) {
	std::sort(s.begin(), s.end());
	s.erase(std::unique(s.begin(), s.end()), s.end());
	return s;
}

int main() {
	int n;
	cin >> n;
	int sum = 0;
	rep(i, n) {
		rep(j, n) {
			rep(s, n) {
				sum += euclidean_gcd(euclidean_gcd(i+1, j+1), s+1);
			};
		};
	};
	cout << sum << endl;
	return 0;
}




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

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<int, int>> d;
    rep(i, a){
        int p;
        cin >> p;
        d.pb({p, 0});
    }
    rep(i, b){
        int q;
        cin >> q;
        d.pb({q, 1});
    }
    rep(i, c){
        int r;
        cin >> r;
        d.pb({r, 2});
    }
    ll ans = 0;
    sort(d.begin(), d.end(), greater<pair<int, int>>());
    int s = 0, t = 0, u = 0;
    int i = 0;
    while(s + t + u < x + y){
        if (d[i].second == 0 && s < x){
            ans += (ll) d[i].first;
            s++;
        }
        if (d[i].second == 1 && t < y){
            ans += (ll) d[i].first;
            t++;
        }
        if (d[i].second == 2){
            ans += (ll) d[i].first;
            u++;
        }
        i++;
    }
    cout << ans << endl;
}

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


int p;
int C[3005][3005];
void Init() {
	C[0][0] = 1;
	for(int i=1; i<=3000; i++) {
		C[i][0] = 1;
		for(int j=1; j<=i; j++) C[i][j] = (C[i-1][j] + C[i-1][j-1])%p;
	}
	return ;
}
int kx[3005];
int main() {
	cin >> p;
	Init ();
	for(int T=0,x; T<p; T++) {
		scanf("%d",&x);
		if(x) {
			kx[0] ++;
			kx[0] %= p;
			int b = 1;
			for(int i=p-1; i>=0; i--) {
				kx[i] = (kx[i]-C[p-1][p-1-i]*b)%p;
				b = (b*-T)%p;
			}
		}
	}
	for(int i=0; i<p; i++) printf("%d ",(kx[i]%p+p)%p);
	return 0;
}

Measured memory_bytes: 34176
def main():

    N = int(input())
    aList = list(map(int,input().split()))

    if N%2 == 0:
        print(' '.join(map(str,aList[-1::-2]+aList[::2])))
    else:
        print(' '.join(map(str,(aList[-1::-2]+aList[1::2]))))


 





if __name__ == "__main__":
    main()

Measured memory_bytes: 122324
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);

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



int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int sum=0;
    sum+=min(a,b);
    sum+=min(c,d);
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3572
w,h,n = map(int,input().split())
x_a = 0
y_a = 0
for i in range(n):
    x,y,a = map(int,input().split())
    
    if a == 1:
        if x < x_a:
            x_a = x_a
        else:
            x_a = x
    elif a == 2:
        if x < w:
            w = x
        else:
            w = w
        
    elif a == 3:
        if y < y_a:
            y_a = y_a
        else:
            y_a = y
    
    elif a == 4:
        if y < h:
            h = y
        else:
            h = h

if w - x_a <= 0 or h - y_a <= 0:
    ans = 0
else:
    ans = (w - x_a)*(h - y_a)

print(ans)

Measured memory_bytes: 9220
N = gets
N.strip!
map = Hash.new
map.default = 0

N.to_i.times do 
  s = gets
  map[s.strip.chars.sort.join] += 1
end
ans = 0

map.each_value{|v|
  if v >= 2 then
    ans += v * (v-1) / 2
  end
}
p ans



Measured memory_bytes: 17020
#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
int main()
{

    int n;
    cin>>n;
    ll mx=0;
    ll sum=0;
    ll a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    mx=a[0];
    for(int i=0; i<n; i++){
        if(mx>=a[i]){
            sum+=(mx-a[i]);
        }
        else{
               mx=a[i];

        }

    }
    cout<<sum<<endl;
     return 0;
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
ll nck(ll n , ll k ,ll m=1e9+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long fact(long long n , long long m = 1e9+7)
{
    long long a = 1 ;
    if(n==0 || n==1)
    {
        return(1) ;
    }
    while(n>0)
    {
        a = (a%m * n%m)%m ;
        n-- ;
    }
    return(a) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y,s;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    char ch,chr ;
    ll a1=0,a2=0,b1=0,b2=0 ;
    cin>>n>>k;
    vll v;
    READ(v,n);
    vll dp(n,1e18);
    dp[0] = 0 ;
    dp[1] = abs(v[1] - v[0]);
    for(i=2 ; i<n;  i=i+1)
    {
        for(j=1 ; j<=k ; j=j+1)
        {
        	if(i-j<0)
        	{
        		break;
			}
			dp[i] = min(dp[i],dp[i-j]+abs(v[i-j]-v[i]));
		}
    }
    cout<<dp[n-1] ;
}

Measured memory_bytes: 1908
import java.util.*;
import java.io.*;

class Main
{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int t = Integer.parseInt(st.nextToken());

        PrintWriter out = new PrintWriter(System.out);

        if(t>=30)
            out.println("Yes");
        else
            out.println("No");

        out.close();
    }
    

}



Measured memory_bytes: 32940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, k; cin >> a >> b >> k;
  vector<int> x(min(a,b));
  for(int i=1;i<=min(a,b);i++) {
    if(a%i==0 && b%i==0) {
      x[i-1]=i;
    }
    else {
      x[i-1]=0;
    }
  }
  sort(x.begin(),x.end());
  reverse(x.begin(), x.end());
  cout << x[k-1] << endl;
}

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

#define N 1000

static char d[N];
static int n;

static void
reverse(d)
char *d;
{
  int i, j;
  
  for (i = 0, j = strlen(d) - 1; i < j; ++i, --j) {
    const char t = d[i];
    d[i] = d[j];
    d[j] = t;
  }
}

static
find(u)
{
  char s[16];
  int i;
  
  for (i = 0; ; ++i) {
    s[i] = u % 10 + '0';
    u /= 10;
    if (u == 0) break ;
  }
  s[i + 1] = '\0';
  return !!(strstr(d, s) != NULL);
}

main()
{
  int i;
  
  scanf("%d", &n);
  for (i = 0; i < n; ++i)
    scanf(" %[0-9]", &d[i]);
  d[n] = '\0';
  reverse(d);

  for (i = 0; ; ++i) {
    if (!find(i)) {
      printf("%d\n", i);
      break ;
    }
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 604
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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

    vector<ll> c(26);
    rep(0, i, 26)
    {
        cin >> c.at(i);
    }

    vector<vector<ll>> s(D, vector<ll>(26, 0));
    rep(0, i, D)
    {
        rep(0, j, 26)
        {
            cin >> s.at(i).at(j);
        }
    }

    ll t;
    ll score = 0;
    vector<vector<ll>> d(D + 1, vector<ll>(26, 0));
    vector<ll> ans(D);
    rep(0, i, D)
    {
        cin >> t;
        t--;
        score += s.at(i).at(t);

        rep(0, j, 26)
        {
            d.at(i + 1).at(j) = d.at(i).at(j) + 1;
        }
        d.at(i + 1).at(t) = 0;

        rep(0, j, 26)
        {
            score -= c.at(j) * d.at(i + 1).at(j);
        }
        ans.at(i) = score;
    }

    rep(0, i, D)
    {
        cout << ans.at(i) << endl;
    }
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
int a[100050], n, s;
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    for (int i = 0; i < n - 1; i++) if (a[i] == a[i + 1]) s++;
    cout << (s % 2 == 0 ? n - s : n - s - 1) << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a[] = new long[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextLong();
		sc.close();
		long ans = 0;
		Arrays.sort(a);
		ans = 5 + ((n / a[0]) - 1);
		if(n % a[0] != 0)ans++;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
#include <cstdio>

using namespace std;

int main(void) {
	int A, B;

	scanf("%d", &A);
	scanf(" %d", &B);

	if (8 < A || 8 < B) printf(":(\n");
	else printf("Yay!\n");
	fflush(stdout);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

mat G(100010);
vec U(100010,-1),V(100010,-1);
void BFSU(int s,int p){
    for(auto t:G[s]){
        if(t==p){continue;}
        U[t]=U[s]+1;
        BFSU(t,s);
    }
}
void BFSV(int s,int p){
    for(auto t:G[s]){
        if(t==p){continue;}
        V[t]=V[s]+1;
        BFSV(t,s);
    }
}
int main(){
    int N,u,v;cin>>N>>u>>v;
    int A,B;
    for(int i=0;i<N-1;i++){
        cin>>A>>B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    U[u]=0;V[v]=0;
    BFSU(u,0);BFSV(v,0);
    int M=-1,ans;
    for(int i=1;i<=N;i++){
        if(G[i].size()==1 && U[i]<V[i]){
            if((V[i]-U[i])%2==0 && 2*(V[i]-1)>M){
                M=2*(V[i]-1);
                ans=V[i]-1;
            }
            if((V[i]-U[i])%2==1 && 2*V[i]-1>M){
                M=2*(V[i]-1);
                ans=V[i]-1;                
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    ll x;
    cin >> x;
    ll n500 = x/500;
    ll n5 = (x - n500*500)/5;
    cout << n500*1000 + n5*5 << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  
  ll n = N / (A + B);
  ll res = N % (A + B);
  ll add = (res >= A) ? A : res;
  ll ret = A * n + add;
  
  cout << ret;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
#define ll long long
#define endl '\n'
const int MAX = 2e5 + 4;
const int MOD = 1e9 + 7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	string hitachi = "hi";
	for (int i = 0; i < s.size(); i+=2)
	{
		if (s.substr(i, 2) != hitachi)
		{
			cout << "No"; return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

int x[100001],a[100001],n,q,sum[100001],tmp;
vector<int> v;
int c1,c9,c7,c4;
int main(void){
    int tmp;
    rep(i,4){
        cin>>tmp;
        if(tmp==1)c1++;
        if(tmp==9)c9++;
        if(tmp==7)c7++;
        if(tmp==4)c4++;
    }
    if(c1&&c9&&c7&&c4)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
int m[51][51],M[51][51];
main(h,w,i,j){
  for(scanf("%d%d",&h,&w),getchar(),i=1;i<=h;getchar(),i++)
    for(j=1;j<=w;j++)
      m[i][j]=getchar()-'0';
  for(i=1;i<=h;i++)M[i][1]=m[i][1]+=m[i-1][1];
  for(j=1;j<=w;j++)M[1][j]=m[1][j]+=m[1][j-1];
  for(i=2;i<=h;i++)
    for(j=2;j<=w;j++)
      M[i][j]=m[i][j]+(M[i-1][j]<M[i][j-1]?M[i-1][j]:M[i][j-1]);
  printf("%d\n",M[h][w]);
  exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int s[11];
int main(){
	int n, m, q, tot, maxn=0;
	cin >> n >> m >> q;
	int a[q+1], b[q+1], c[q+1], d[q+1];
	for (int i=1; i<=q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	while (s[0]!=1){
		tot=0;
		s[n]++;
		int x=n;
		while (s[x]>=m&&x>0){
			s[x-1]++;
			x--;
			for (int i=x+1; i<=n; i++) s[i]=s[x];
		}
		for (int i=1; i<=q; i++)
			if (s[b[i]]-s[a[i]]==c[i]) tot+=d[i];
		maxn=max(maxn, tot);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

ll my_lower_bound(ll* beg, ll* end, ll val){

    ll mid = 0;
    ll l = 0;
    ll r = end - beg;

    while(l < r) {
        mid = (l + r)/2;
        if(val > *(beg + mid)) {
            l = mid + 1;
        } else{
            r = mid; 
        }
    }
    return l;
}

// https://www.geeksforgeeks.org/upper_bound-in-cpp/

// ll my_upper_bound(ll val, ll* target, size_t tsize){
ll my_upper_bound(ll* beg, ll* end, ll val){


    ll mid = 0;
    ll l = 0;
    ll r = end - beg;

    while(l < r) {
        mid = (l + r)/2;
        if(val < *(beg+mid)) {
            r = mid;
        } else{
            l = mid + 1; 
        }
    }

    return l;
}

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

    ll *a,*b,*c;
    a = new ll[n];
    b = new ll[n];
    c = new ll[n];

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

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

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

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    size_t sum = 0;
    for(size_t i = 0; i < n; ++i) {

        // lower bound search : 最低k以上の要素を探す
        // upper bound search : 最高k未満の要素を探す
        // ll num_c = my_lower_bound(b[i], c, n);
        // ll num_a = my_upper_bound(b[i], a, n);
        auto iter_a = my_lower_bound(a, a+n, b[i]);
        auto iter_c = my_upper_bound(c, c+n, b[i]);

        // ll val_a = iter_a - a;
        ll val_a = iter_a;
        // ll val_c = c+n - iter_c;
        ll val_c = n - iter_c;
        

        sum += val_a * val_c;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int w, n, a, b, r[31], i, t;

  for (i = 1; i <= 30; i++) {
    r[i] = i;
  }

  cin >> w >> n;
  for (i = 0; i < n; i++) {
    scanf("%d,%d", &a, &b);
    t = r[a];
    r[a] = r[b];
    r[b] = t;
  }

  for (i = 1; i <= w; i++) {
    cout << r[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, m;
int par[100010], Rank[100010];
int SIZE[100010];

void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        Rank[i] = 0;
        SIZE[i] = 1;
    }
}
int find(int x)
{
    if (par[x] == x)
        return x;
    else
        return par[x] = find(par[x]);
}
void unit(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        SIZE[y] += SIZE[x];
    }
    else
    {
        par[y] = x;
        SIZE[x] += SIZE[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}
bool same(int x, int y)
{
    return find(x) == find(y);
}

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

    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    rep(i, m) a[i]--, b[i]--;
    reverse(all(a)), reverse(all(b));
    init(n);
    vector<int> ans(m);
    int S = (n * (n - 1)) / 2;
    ans.push_back(S);
    unit(a[0], b[0]);
    int tmp = 1;
    Rep(i, 1, m)
    {
        if (same(a[i], b[i]))
        {
            ans.push_back(S - tmp);
            continue;
        }
        ans.push_back(S - tmp);
        tmp += SIZE[find(a[i])] * SIZE[find(b[i])];
        unit(a[i], b[i]);
    }
    reverse(all(ans));
    rep(i, m) cout << ans[i] << endl;
}

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

typedef long long ll;

int main(){
    ll a,b; cin >> a >> b;
    ll c=__gcd(a,b);
    vector<ll> divisor;
    for(ll i=1;i*i<=c;i++){
        if(c%i==0){
            divisor.push_back(i);
            if(i!=c/i) divisor.push_back(c/i);
        }
    }
    sort(divisor.begin(),divisor.end());
    int ans=0;
    /*
    for(int i=0;i<divisor.size();i++){
        cout << divisor[i] << " ";
    }
    cout << endl;
    */
    for(int i=0;i<divisor.size();i++){
        bool flag=true;
        for(int j=0;j<i;j++){
            if(__gcd(divisor[i],divisor[j])!=1){
                flag=false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main() {
    string num;
    int a = 0;
    int b = 0;
    int i;

    while (1) {
        cin >> num;
        if (num == "0") break;
        int a = 0, b = 0, i;
        for (i = 0; i < num.length(); ++i) {
            a = num[i] - '0';
            b = b + a;
        }
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int UF[100];
pair<double,pair<int,int> > e[10000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);
	b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
double x[100],y[100],z[100],r[100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			UF[i]=-1;
			scanf("%lf%lf%lf%lf",x+i,y+i,z+i,r+i);
		}
		int now=0;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				e[now++]=make_pair(max(0.0,-r[i]-r[j]+sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))),make_pair(i,j));
			}
		}
		std::sort(e,e+now);
		double ret=0;
		for(int i=0;i<now;i++){
			if(FIND(e[i].second.first)!=FIND(e[i].second.second)){
				UNION(e[i].second.first,e[i].second.second);
				ret+=e[i].first;
			}
		}
		printf("%.3f\n",ret);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,q;
    cin >> n;
    int S[n];
    for(int i=0;i<n;i++){
        cin >> S[i];
    }
    cin >> q;
    int T[n];
    for(int i=0;i<q;i++){
        cin >> T[i];
    }
    sort(T, T + q); 

    int count = 0;
    int i=0;
    int j=0;
    while(true){
        while(true){
            if(T[i]==S[j]){
                count++;
                break;
            }else if(T[i]<S[j+1]){
                break;
            }
            j++;
        }
        i++;
        if(i==q) break;
    }

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



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

void solve() 
{
    ll m = 100,c=0;
    ll x;cin>>x;
    while(m<x){
        m*=1.01;
        c++;
    }
    cout<<c<<endl;
}

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

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string s[109];
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)
		cout<<s[i];
	return 0;
}

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

int main(){
  int a[8][3]={
    {0,0,0},
    {0,1,1},
    {1,0,1},
    {1,1,0},
    {0,0,1},
    {0,1,0},
    {1,0,0},
    {1,1,1}
  };
  int N;
  string s;
  cin >> N >> s;
  string t;
  for(int i=0; i<4; i++){
    int cnt=0;
    int l;
    vector<int> u(N);
    if(s.at(0)=='o') l=i;
    if(s.at(0)=='x') l=i+4;
    u.at(0)=a[l][1];
    u.at(1)=a[l][2];
    for(int j=1; j<N-1; j++){
      if(s.at(j)=='o'){
        if(u.at(j-1)==0 && u.at(j)==0) u.at(j+1)=0;
        if(u.at(j-1)==0 && u.at(j)==1) u.at(j+1)=1;
        if(u.at(j-1)==1 && u.at(j)==0) u.at(j+1)=1;
        if(u.at(j-1)==1 && u.at(j)==1) u.at(j+1)=0;
      }
      if(s.at(j)=='x'){
        if(u.at(j-1)==0 && u.at(j)==0) u.at(j+1)=1;
        if(u.at(j-1)==0 && u.at(j)==1) u.at(j+1)=0;
        if(u.at(j-1)==1 && u.at(j)==0) u.at(j+1)=0;
        if(u.at(j-1)==1 && u.at(j)==1) u.at(j+1)=1;
      }
    }
    if(s.at(N-1)=='o'){
        if(u.at(N-2)==0 && u.at(N-1)==0 && u.at(0)==1) cnt=-1;
        if(u.at(N-2)==0 && u.at(N-1)==1 && u.at(0)==0) cnt=-1;
        if(u.at(N-2)==1 && u.at(N-1)==0 && u.at(0)==0) cnt=-1;
        if(u.at(N-2)==1 && u.at(N-1)==1 && u.at(0)==1) cnt=-1;
      }
    if(s.at(N-1)=='x'){
        if(u.at(N-2)==0 && u.at(N-1)==0 && u.at(0)==0) cnt=-1;
        if(u.at(N-2)==0 && u.at(N-1)==1 && u.at(0)==1) cnt=-1;
        if(u.at(N-2)==1 && u.at(N-1)==0 && u.at(0)==1) cnt=-1;
        if(u.at(N-2)==1 && u.at(N-1)==1 && u.at(0)==0) cnt=-1;
      }
    if(a[l][0]!=u.at(N-1)) cnt=-1;
    if(cnt!=-1){
      for(int j=0; j<N; j++){
        if(u.at(j)==0) t+='S';
        else t+='W';
      }
      break;
    }
  }
  if(t.size()==0) cout << -1 << endl;
  else cout << t << endl;
}

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


int main()
{
    ll a,b,c,d,e,f,i,j;
    cin>>a;
    f=0;
    b=1e9;
    for(i=0;i<a;i++)
    {
        cin>>c;
        if(i==0)
        {
            f++;
            b=c;
            continue;
        }
        if(c<=b)f++;
        b=min(c,b);
    }
    cout<<f<<endl;
}


Measured memory_bytes: 256
#include<cstdio>

int a[1000];

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	long long ans = 0;
	for(int i=39;i>=0;i--) {
		long long x = ans | (1ll << i);
		int count = 0;
		for(int i=0;i<n;i++) {
			long long sum = 0;
			for(int j=i;j<n;j++) {
				sum += a[j];
				if((sum & x) == x) count++;
			}
		}
		if(count >= k) ans |= (1ll << i);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin >> a >> b;
    a = __gcd(a, b);
    ll ans = 1;
    for (ll i = 2; i * i <= a; i++) {
        if (a % i == 0) {
            while (a % i == 0) a/= i;
            ++ans;
        }
    }
    if (a > 1) ++ans;
    cout << ans << '\n';
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5))
  {
    cout<<"YES";
  }
  else
  {
    cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

ll gcd(ll A, ll B) {
    if (A < B) return gcd(B, A);
    if (B == 0) return A;
    return gcd(B, A%B);
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll C = gcd(A, B);
    int Res = 1;
    for (ll i = 2; i * i <= C; ++i) {
        if (C%i == 0) {
            ++Res;
            while (C%i == 0) C /= i;
        }
    }
    if (C != 1) ++Res;
    
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	int e,m,a;
	
	while(1){
		cin >> e;
		m=e;
		if(e==0){
			return 0;
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<m-i;j++){
				a=e-i*(i-1)-j*(j-1)*(j+1);
				if((a>=i+j)&&(m>a)&&(a>=0)){
					m=e-i*(i-1)-j*(j-1)*(j+1);
				}
				if(a<0){
					break;
				}
			}
		}
		cout << m <<"\n";
	}
			
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 100000000
#define N 10000
ll tra[10000];
int main()
{
    ll n;
    cin>>n;
    ll lock=0;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i==1 ||( i%3!=0 && i%5!=0))
            sum+=i;


    }
   cout<<sum<<endl;

}


Measured memory_bytes: 3636
#A

n = int(input())

if n // 100 == 7:
    print('Yes')
    exit()

else :
    a = n // 100

    n_2 = n - a * 100

    if n_2 // 10 == 7:
        print('Yes')
        exit()

    else :
        b = n_2 // 10

        n_3 = n_2 - b * 10

        if n_3 == 7:
            print('Yes')
            exit()
    
print('No')

Measured memory_bytes: 9196
#include<iostream>
#include<complex>
#include<map>

#define fs first
#define sc second
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-8;
double cross(P x,P y){return imag(conj(x)*y);}
bool para(L a,L b){return abs(cross(a.fs-a.sc,b.fs-b.sc))<EPS;}

int main(){
  int n;
  P p[4];
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++)cin >> p[j].real() >> p[j].imag();
    cout << (para(L(p[0],p[1]),L(p[2],p[3]))?"YES":"NO") << endl;
  }
}

Measured memory_bytes: 1228
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define vi vector<int>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
typedef long long ll;
typedef short inth;
 
const int N = 80;
const int M = N + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 17;

int a[M];
ll dp[M];

int main() {
    int n;
    scanf("%d", &n);
    dp[0] = 1000;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        for (int j = 0; j < i; ++j) {
            int mn = 200;
            for (int k = max(1, j); k <= i; ++k)
                mn = min(mn, a[k]);
            ll cur = dp[j] % mn;
            cur += 1LL * (dp[j] / mn) * a[i];
            dp[i] = max(dp[i], cur);
        }
    }
    printf("%lld", dp[n]);
    return 0;
}

Measured memory_bytes: 3840
import java.util.*;
public class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	
	int z =0;
		for(int i = a; i<b+1; i++){
			if(c % i  == 0){
			z++;
			}
		}
				System.out.println(z);
	}
}


Measured memory_bytes: 26260
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<cmath>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,k;
  cin >> n >> k;
  double l=0,r=1e16;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int _=0;_<100;_++){
    double h = (l+r)/2;
    ll sum = 0;
    for(int i=0;i<n;i++){
      sum += (ll)floor(a[i]/h);
    }
    if(sum>k){
      l = h;
    }else{
      r = h;
    }
  }
  cout << (ll)ceil(l) << endl;
}


Measured memory_bytes: 4796
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// Q3
int main()
{
	long long nA, nB;
	cin >> nA >> nB;
	if (nA < nB)
		swap(nA, nB);
	long long lnX = nA*nB;

	long long nR = nA% nB;
	while (nR != 0)
	{
		nA = nB;
		nB = nR;
		nR = nA % nB;
	}
	cout << lnX/nB;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[100005];

int main()
{
	int n;
	memset(x,0,sizeof(x));
	cin >> n;
	int a[n],max = 0;
	
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] > max) max = a[i];
		x[a[i] - 1]++;
		x[a[i]]++;
		x[a[i] + 1]++;
	}
	
	int max2 = 0;
	for(int i = 0;i <= max + 1;i++){
		if(x[i] > max2) max2 = x[i];
	}
	cout << max2;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    // 解説AC
    int n, m;
    cin >> n >> m;

    vector<int> a(n+1, true);
    for (int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        a[tmp] = false;
    }

    vector<ll> dp(n+1);
    dp[0] = 1;
    for (int now = 0; now < n; now++) {
        for (int next = now + 1; next <= min(n, now + 2); next++) {
            if (a[next]) {
                dp[next] += dp[now];
                dp[next] %= MOD;
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
    
     

/* bit tannsaku?
    int n, m;
    cin >> n >> m;

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

    ll ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {

        int height = 0;
        
        for (int i = 0; i < n; i++) {
        
            bool can = true;
            for (int k = 0; k < m; k++) {
                if(height == a[k]) can = false;
            }
            if (!can) {
                break;
            }
            
            if (bit & (1 << i)) {
                height += 2;
            } else {
                height += 1;
            }
            if (height >= n) {
                break;
            }
        }
       
        if(height == n) {
            ans++;
            ans %= MOD;
        }
        
    }
    
    cout << ans << endl;

    return 0;
    */
}

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

int main(){
    int A, B, C, N, M ,K, T, X;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> T >> X;
    cout << (double)T/X << endl;
//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h, w;

        while (true) {
            h = scan.nextInt();
            w = scan.nextInt();

            if (h == 0 && w == 0)
                return;

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 37716
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,i;
    ll a,b,c,k;

    cin>>a>>b>>c;
    cin>>k;

    while(b<=a && k>0)
    {
        b*=2;
        k--;
    }

    while(c<=b && k>0)
    {
        c*=2;
        k--;
    }
   // cout<<a<<" "<<b<<" "<<c<<'\n';
    if(c>b && c>a && b>a)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3644
// by ul {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

int N;
vector<PII> v;
void input() {
    RI(N);
    REP(i, N) {
        int a; RI(a);
        v.PB({a, i+1});
    }
}

void solve() {
    sort(ALL(v));
    REP(i, N) {
        if(i == N-1) 
            printf("%d\n", v[i].second);
        else
            printf("%d ", v[i].second);
    }
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1780
import java.util.Scanner;

 class Main {
 public static void main(String[] args) {
  Scanner scan = new Scanner(System.in);
  int W, H, x, y, r;

  W = scan.nextInt();
  H = scan.nextInt();
  x = scan.nextInt();
  y = scan.nextInt();
  r = scan.nextInt();

  if (x < -100 || y < -100 || 100 < x || 100 < y || W <= 0 || H <= 0
    || r <= 0 || 100 < W || 100 < H || 100 < r) {
   throw new RuntimeException("error");
  }
  if (0 <= (x - r) && (x + r) <= W && 0 <= (y - r) && (y + r) <= H) {
   System.out.println("Yes");
  } else {
   System.out.println("No");
  }
 }
}

Measured memory_bytes: 17324
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
ll dp[100010][3];
int main(){
    string s;cin>>s;
    ll counter=1;
    if(s[0]=='A')dp[0][0]++;
    if(s[0]=='?'){
        dp[0][0]++;
        counter*=3%inf;
    }
    REP(i,1,s.size()){
        if(s[i]=='A'){
            dp[i][0]=(dp[i][0]+dp[i-1][0]+counter)%inf;
            dp[i][1]=(dp[i][1]+dp[i-1][1])%inf;
            dp[i][2]=(dp[i][2]+dp[i-1][2])%inf;
        }
        if(s[i]=='B'){
            dp[i][0]=(dp[i][0]+dp[i-1][0])%inf;
            dp[i][1]=(dp[i][1]+dp[i-1][0]+dp[i-1][1])%inf;
            dp[i][2]=(dp[i][2]+dp[i-1][2])%inf;
        }
        if(s[i]=='C'){
            dp[i][0]=(dp[i][0]+dp[i-1][0])%inf;
            dp[i][1]=(dp[i][1]+dp[i-1][1])%inf;
            dp[i][2]=(dp[i][2]+dp[i-1][1]+dp[i-1][2])%inf;
        }
        if(s[i]=='?'){
            dp[i][0]=(dp[i][0]+dp[i-1][0]+counter)%inf;
            dp[i][1]=(dp[i][1]+dp[i-1][1])%inf;
            dp[i][2]=(dp[i][2]+dp[i-1][2])%inf;
            dp[i][0]=(dp[i][0]+dp[i-1][0])%inf;
            dp[i][1]=(dp[i][1]+dp[i-1][0]+dp[i-1][1])%inf;
            dp[i][2]=(dp[i][2]+dp[i-1][2])%inf;
            dp[i][0]=(dp[i][0]+dp[i-1][0])%inf;
            dp[i][1]=(dp[i][1]+dp[i-1][1])%inf;
            dp[i][2]=(dp[i][2]+dp[i-1][1]+dp[i-1][2])%inf;
            counter=(counter*3)%inf;
        }
    }
    cout<<dp[s.size()-1][2]<<endl;
}

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

ll fep(ll x, ll y, ll m)
{
	//base cases
	if (x == 0)
		return 0;
	if (y == 0)
		return 1;

	//terminating condition
	if (y == 1)
		return (x % m);

	if (y % 2)
		return ((fep(x, y - 1, m) * fep(x, 1, m)) % m);
	else
	{
		ll t = fep(x, y / 2, m);
		return (t * t) % m;
	}
}

ll solve()
{
	ll s;
	cin >> s;

	vector<ll> dp(4000, 0);
	dp[0] = 1;
	for (ll i = 1; i < 4000; i++)
		dp[i] = (dp[i - 1] * i) % M;

	ll ret = 0, a, b, c;
	for (ll i = 1; i <= (s / 3); i++)
	{
		a = dp[s - 2 * i - 1];
		b = dp[s - 3 * i];
		c = dp[i - 1];
		b = (b * c) % M;
		ret = (ret + (a * fep(b, M - 2, M)) % M) % M;
	}

	return ret;
}

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

	ll t;
	// cin >> t;
	t = 1;
	for (ll i = 1; i <= t; i++)
		cout << solve() << "\n";

	return 0;
}


Measured memory_bytes: 3680
def main():
  r1,c1,r2,c2 = map(int,input().split())

  mod = 10**9+7

  fact = [1,1]
  finv = [1,1]
  inv = [0,1]

  for i in range(2,r2+c2+3):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)

  def nCr(n,r,mod):
      
      return fact[n]*finv[r]*finv[n-r]%mod

  print((nCr(r2+c2+2,r2+1,mod)+nCr(r1+c1,r1,mod)-nCr(c2+r1+1,r1,mod)-nCr(r2+c1+1,c1,mod))%mod)

if __name__ == "__main__":
  main()

Measured memory_bytes: 132916
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0}
for _ in[0]*int(input()):
 L=[];t=''
 for e in input()[:-1]:
  if e.isdigit():t+=e
  else:
   if t:L+=[t];t=''
   L+=e
 if t:L+=[t]
 P,S=[],[]
 for i in L:
  if"("==i:S+=i
  elif")"==i:
   while"("!=S[-1]:P+=S.pop()
   S.pop()
  elif i in R:
   while S and R[S[-1]]>=R[i]:P+=S.pop()
   S+=i
  else:P+=[i]
 while S:P+=S.pop()
 for x in P:S+=[str(int(eval(S.pop(-2)+x+S.pop())))if x in"+-*/"else x]
 print(*S)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n>>k;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    sort(p,p+n);
    int ans=1e9;
    for(int i=0;i<n-k+1;i++){
        ans=min(ans,p[i+k-1]-p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100005;
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  int a,b;
  a = (s[0]-'0')*10+(s[1]-'0');
  b = (s[2]-'0')*10+(s[3]-'0');
  if (1 <= a && a <= 12)
  {
    if (1 <= b && b <= 12)
      cout << "AMBIGUOUS";
    else
      cout << "MMYY";
  }
  else
  {
    if (1 <= b && b <= 12)
      cout << "YYMM";
    else
      cout << "NA";
  }
  return 0;
}


Measured memory_bytes: 384