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

const int mod = 1e9+7;
int row,col,dp[10005][10005];
char grid[10005][10005];

void addSelf(int &x,int y)
{
    x += y;
    if(x >= mod)
        x -= mod;
}

void FuN()
{
    for(int i=1 ; i<=row ; i++){
        for(int j=1 ; j<=col ; j++){
            if(grid[i][j] == '#')
                continue;
            if(i == 1 && j == 1)
                dp[i][j] = 1;
            else{
                addSelf(dp[i][j] , dp[i-1][j]);
                addSelf(dp[i][j] , dp[i][j-1]);
            }
        }
    }
    cout<<dp[row][col]<<endl;
}

int main()
{
    cin>>row>>col;
    for(int i=1 ; i<=row ; i++){
        for(int j=1 ; j<=col ; j++)
            cin>>grid[i][j];
    }
    FuN();
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, a, b;
    cin >> n >> a >> b;
    if(n + 1 < a + b){
        cout << -1 << endl;
        return 0;
    }
    if(b == 1){
        if(a != n){
            cout << -1 << endl;
            return 0;
        }
        for(int i = 1; i <= n; i++){
            cout << i << endl;
        }
        return 0;
    }
    vector<int> ans;
    for(int i = n - a + 1; i <= n; i++){
        ans.push_back(i);
    }
    b--;
    int now = n - a + 1;
    if(b > now){
        cout << -1 << endl;
        return 0;
    }
    while(true){
        a = min(a, now - 1);
        a = min(a, now - 1 - (b - 1));
        //cout << now << " " <<  a << endl;
        if(a == 0) break;
        if(b == 0){
            cout << -1 << endl;
            return 0;
        }
        b--;
        for(int i = now - a; i < now; i++){
            ans.push_back(i);
        }
        now = now - a;
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << " ";
    }
    for(int i = 1; i <= n - ans.size(); i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3440
#include<stdio.h>
#include<string.h>
#define N 1000000
#define NIL (-1)
#define L 12

char H[N][L];

int getChar(char);
long long getkey(char *);
int h1(int);
int h2(int);
int find(char *);
int insert(char *);


int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<N;i++) H[i][0]='\0';
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }else{
      if(find(str)==1){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }

  }

  return 0;
}


int getChar(char str){
  if(str == 'A') return 1;
  else if(str =='C') return 2;
  else if(str =='G') return 3;
  else if(str == 'T') return 4;
  else return 0;

}

long long getkey(char *str){

  long long sm=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sm+=p*(getChar(str[i]));
    p*=5;
  }
  return sm;
}

int h1(int key){
  return key%N;
}

int h2(int key){
  return 1+(key%(N-1));
}

int find(char *str){
  long long key,i,h;
  key =getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%N;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char *str){
  long long key,i,h;

  key = getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%N;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }

  }
  return 0;
}



Measured memory_bytes: 13508
#include <cstdio>

int main()
{
  int h, m, s;
  while (scanf("%d %d %d", &h, &m, &s)) {
    if (h == -1 && m == -1 && s == -1)
      break;
    int n_rem = 120 * 60 - (h * 3600 + m * 60 + s);
    printf("%02d:%02d:%02d\n", n_rem/3600, n_rem%3600/60, n_rem%60);
    n_rem *= 3;
    printf("%02d:%02d:%02d\n", n_rem/3600, n_rem%3600/60, n_rem%60);
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    unordered_map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
    mp[s]++;
    }
    
    ll ans = 0;
    for( auto& p :mp){
        int s=p.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
    return 0;
    }

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

string to_string(string s) {
 return '"' + s + '"';
}

string to_string(const char* ch) {
 return to_string((string)ch);
}

string to_string(char ch) {
 return (string)"'" + ch + (string)"'";
}

string to_string(bool b) {
 return (b ? "true" : "false");
}

template<class A, class B>
string to_string(pair<A, B> p) {
 return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<class A>
string to_string(A a) {
 string res = "{";
 bool first = true;
 for(const auto& x: a) {
  if(first == false) res += ", ";
  first = false;
  res += to_string(x);
 }
 res += "}";
 return res;
}

void debug() {cerr << "]\n";}

template<class H, class... T>
void debug(H head, T... tail) {
 cerr << to_string(head) << " ";
 debug(tail...);
}

#ifdef LOCAL
 #define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else 
 #define debug(...) 
#endif

int main() 
{
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 int n;
 cin >> n;
 vector<double> a(n);
 for(double& i: a) cin >> i;
 vector<vector<double>> dp(n+1, vector<double> (n+1, 0.0));
 dp[0][0] = 1.0;
 for(int i = 1; i <= n; i++) {
  for(int j = 0; j <= i; j++) {
   dp[i][j] = dp[i-1][j] * (1.0 - a[i-1]) + (j ? dp[i-1][j-1] : 0.0) * a[i-1];
  }
 }
 debug(dp);
 double ans = 0;
 for(int i = n / 2 + 1; i <= n; i++) ans += dp[n][i];
 cout << fixed << setprecision(10) << ans << '\n';
 return 0;
}


Measured memory_bytes: 73780
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int a[300][300];
vector<P>v[300];
bool flag[300];
int cnt[300];

signed main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, n)rep(j, m) {
		scanf("%d", &a[i][j]); a[i][j]--;
	}
	int l = 0, r = n;
	while (l != r) {
		memset(cnt, 0, sizeof(cnt));
		rep(i, m)v[i].clear();
		rep(i, n) {
			v[a[i][0]].push_back(P(i, 0));
			cnt[a[i][0]]++;
		}
		int t = (l + r) / 2;
		memset(flag, 1, sizeof(flag));
		while (1) {
			int c = 0;
			rep(i, m) {
				if (!(flag[i] && cnt[i] > t))continue;
				c++;
				flag[i] = false;
				for (P j : v[i]) {
					while (j.second < m && !flag[a[j.first][j.second]])j.second++;
					if (j.second == m)goto g;
					cnt[a[j.first][j.second]]++;
					v[a[j.first][j.second]].push_back(j);
				}
			}
			if (c == 0)break;
		}
		r = t;
		continue;
	g:;
		l = t + 1;
	}
	printf("%d\n", l);
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n);
    rep(i, n) cin >> a[i];
    priority_queue<int> q;
    rep(i, n) q.push(a[i]);
    rep(i, m) {
        int p = q.top(); q.pop();
        q.push(p/2);
    }
    ll sum = 0;
    while (!q.empty()) {
        int p = q.top(); q.pop();
        sum += p;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (B <= A) {
			System.out.println("delicious");
		} else if (B <= X + A) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 22868
a,b,c,d=map(int,input().split())
Str = ""
U_1st_num = d-b
for i in range(U_1st_num):
  Str = Str + "U"
R_1st_num = c-a
for i in range(R_1st_num):
  Str = Str + "R"
D_2nd_num = d-b
for i in range(D_2nd_num):
  Str = Str + "D"
L_2nd_num = c-a
for i in range(L_2nd_num):
  Str = Str + "L"
Str = Str + "L"
for i in range(U_1st_num+1):
  Str = Str + "U"
for i in range(R_1st_num+1):
  Str = Str + "R"
Str = Str + "D"
Str = Str + "R"
for i in range(D_2nd_num+1):
  Str = Str + "D"
for i in range(L_2nd_num+1):
  Str = Str + "L"
Str = Str + "U"
print(Str)

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

int main()
{
    int a,b,c,d,e;
    cin >>a >>b >>c >>d >>e;
    if (a==0){cout <<1;}
    else if (b==0){cout <<2;}
    else if (c==0){cout <<3;}
    else if (d==0){cout <<4;}
    else {cout <<5;}
    return 0;


}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> cnt;
long long sum=0;
int main() {
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);
	long long n,q,x,y;
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>x,cnt[x]++,sum+=x;
	cin>>q;
	for(int i=1; i<=q; i++) {
		cin>>x>>y;
		sum-=cnt[x]*x;
		cnt[y]+=cnt[x];
		sum+=y*cnt[x];
		cnt[x]=0;
		cout<<sum<<endl;
	}
	return 0;
}
//475254

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        x--;
        g[x].emplace_back(i);
        p[i] = x;
    }

    vector<bool> trk(n);
    int x = 0;
    while (!trk[x]) {
        trk[x] = true;
        x = p[x];
    }
    vector<bool> cyc(n);
    while (!cyc[x]) {
        cyc[x] = true;
        x = p[x];
    }

    vector<set<int>> sub(n);
    vector<int> a(n);
    auto mex = [&](int u){
        int i = 0;
        while (sub[u].find(i) != sub[u].end()) {
            i++;
        }
        return i;
    };
    function<void(int)> dfs = [&](int u){
        for (int v: g[u])if(!cyc[v]){
            dfs(v);
            sub[u].insert(a[v]);
        }
        if (!cyc[u]) {
            a[u] = mex(u);
        }
    };
    for (int i = 0; i < n; i++) {
        if(cyc[i]) dfs(i);
    }

    auto snd_sub = sub;
    {
        a[x] = mex(x);
        sub[p[x]].insert(a[x]);
        int y = p[x];
        while (y != x) {
            a[y] = mex(y);
            sub[p[y]].insert(a[y]);
            y = p[y];
        }
        if (a[x] == mex(x)) {
            cout << "POSSIBLE"; return;
        }
    }
    swap(snd_sub, sub);
    {
        int pre = mex(x);
        sub[x].insert(pre);
        a[x] = mex(x);
        sub[p[x]].insert(a[x]);
        int y = p[x];
        while (y != x) {
            a[y] = mex(y);
            sub[p[y]].insert(a[y]);
            if (p[y] == x) {
                if (a[y] == pre) {
                    cout << "POSSIBLE"; return;
                }
            }
            y = p[y];
        }
    }
    cout << "IMPOSSIBLE"; return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 44160
#include <queue>
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, R, L, D, T, X, M[100000], A[100000]; vector<pair<int, int> > F[1000000]; // (team, score)
int main() {
	scanf("%d%d%d", &N, &R, &L);
	for (int i = 0; i < R; i++) {
		scanf("%d%d%d", &D, &T, &X);
		F[T].push_back(make_pair(D - 1, X));
	}
	priority_queue<pair<int, int> > que;
	for (int i = 0; i < N; i++) {
		que.push(make_pair(0, -i));
	}
	for (int i = 0; i < L; i++) {
		for (int j = 0; j < F[i].size(); j++) {
			M[F[i][j].first] += F[i][j].second;
			que.push(make_pair(M[F[i][j].first], -F[i][j].first));
		}
		pair<int, int> p;
		while (true) {
			p = que.top();
			if (p.first == M[-p.second]) break;
			que.pop();
		}
		A[-p.second]++;
	}
	int ret = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] > A[ret]) {
			ret = i;
		}
	}
	printf("%d\n", ret + 1);
	return 0;
}

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

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

  if ((a % 2) * (b % 2) == 1 ) {
    cout << "Odd" << endl;
  }

  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
//#define DEBUG
//#define RANDOM
typedef long long ll;
typedef long double ld;
using namespace std;

const ll mod = 998244353;
class segment
{
public:
    int l, r;
};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> d(2 * n + 79, 0);
    d[1] = 1;
    d[2] = mod - 1;
    vector<segment>v(k);
    for (int i = 0; i < k; i++)
    {
        cin >> v[i].l >> v[i].r;
    }
    ll curr = 0;
    for (int i = 1; i <=  n; i++)
    {
        curr += d[i];
        if (curr >= mod)
        {
            curr -= mod;
        }
        for (segment& s : v)
        {
            d[i + s.l] += curr;
            if (d[i + s.l] >= mod)
            {
                d[i + s.l] -= mod;
            }
            d[i + s.r + 1] -= curr;
            if (d[i + s.r + 1] < 0)
            {
                d[i + s.r + 1] += mod;
            }
        }
    }
    cout << curr << "\n";
    return 0;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll n; 
ll h[100010];
ll dp[100010];
int main(){
    cin >> n;
    rep(i,n) cin >> h[i];
    rep(i,100010) dp[i] = INFINITY;
    dp[0] = 0;

    _rep(i,1,n){
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1)dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

int main(){
	ll n,m,a[100010];
	ll ans=0;
	cin >> n >> m;
	FOR(i,n){
		cin >> a[i];
	}
	ll sum=0;
	vector<ll> v;
	FOR(i,n){
		sum+=a[i];
		v.push_back(sum%m);
	}

	v.push_back(0ll);
	sort(all(v));
	ll nowi=v[0],cnt=1;
	for(int i=1;i<n+1;i++){
		if(nowi==v[i]){
			cnt++;
		}else{
			ans+=cnt*(cnt-1)/2;
			cnt=1;
			nowi=v[i];
		}
	}
	ans+=cnt*(cnt-1)/2;
	cout << ans << endl;
}

Measured memory_bytes: 2168
using namespace std;
int main(){
	double a[8]; bool f;
	while(1){
		for(int i=0;i<8;i++)f=cin>>a[i];
		if(!f)break;
		double cx,cy,w,h,x,y;
		cx=a[0]+a[2],cy=a[1]+a[3];
		x=a[4]+a[6],y=a[5]+a[7];
		w=a[2]-a[0]+a[6]-a[4],h=a[3]-a[1]+a[7]-a[5];
		cout<<(cx-w<=x&&x<=cx+w&&cy-h<=y&&y<=cy+h?"YES":"NO")<<endl;
	}
	return 0;
}

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

const int N = 1e3 + 3;
const int W = 1e4 + 4;
int w[N] , s[N] , v[N];
long long dp[N][W];
int idx[N];
int n;

long long solve(int i , int weight){
    if(weight >= W)return 0;
    if(i == n)return 0;
    long long &ret = dp[i][weight];
    if(~ret)return ret;
    ret = solve(i+1,weight);
    if(weight <= s[idx[i]])
        ret = max(ret , solve(i+1,weight+w[idx[i]]) + v[idx[i]]);
    return ret;
}


int main(){

    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d%d%d",&w[i],&s[i],&v[i]);
        idx[i] = i;
    }

    sort(idx,idx+n,[&](int i , int j){
            return s[i] + w[i] < s[j] + w[j];
        });

    memset(dp,-1,sizeof dp);
    printf("%lld\n",solve(0,0));

    return 0;
}


Measured memory_bytes: 78720
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18, cs;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

    cin>>a>>b>>c>>d;
    ll a1=b*d;
    ll a2=a*d;
    ll a3=a*c;
    ll a4=b*c;
    cout<<max(a1,max(a2,max(a3,a4)))<<endl;


    //code
    return 0;
}




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

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

    int error_cnt = 0;
    for(int i=0; i<n; i++){
        if(p[i] != i+1){
            error_cnt++;
        }
    }
    if(error_cnt<=2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
map<string,ll>M,M2;
vector<int>divv[105];
struct Takagaki{
	ll rec(string s){
	    if(s.size() == 1) return (s=="*"?2:1);
		if(M.find(s) != M.end()) return M[s];
		int n = s.size();
		for(int ii=0;ii<divv[n].size();ii++){
			int m = divv[n][ii];
			string nxt = "";
			for(int i=0;i<n/m;i++){
				bool z=1,o=1;
				for(int j=0;j<m;j++){
					int cur = j*(n/m)+i;
					if(s[cur] == '0') o = 0;
					else if(s[cur] == '1') z = 0;
				}
				if(!z && !o) goto fail;
				else if(z && o) nxt.pb('*');
				else if(z) nxt.pb('0');
				else nxt.pb('1');
			}
			M[s] += rec2(nxt);
			fail:;
		}
		M[s] %= mod;
		return M[s];
	}
	ll rec2(string s){
		if(s.size() == 1) return (s=="*"?2:1);
		if(M2.find(s) != M2.end()) return M2[s];
		ll dp[105]={};
		dp[0] = 1;
		int n = s.size();
		for(int i=1;i<=n;i++){
			for(int j=0;j<i;j++){
				string str = "";
				for(int k=j;k<i;k++) str.pb((s[k]=='1'?'*':s[k]));
				dp[i] += dp[j] * rec(str) % mod;
				dp[i] %= mod;
			}
			//cout << dp[i] << endl;
		}
		return M2[s] = dp[n];
	}
}kaede;
int main(){
	cin >> s;
	int n = s.size();
	divv[1].pb(1);
	for(int i=2;i<=100;i++){
		for(int j=2;j<=i;j++) if(i%j == 0) divv[i].pb(j);
	}
	for(int i=0;i<n;i++) if(s[i] == '1') s[i] = '*';
	cout << kaede.rec2(s) << endl;
}

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

int main(){
  int N , K; cin >> N >> K;
  string S; cin >> S;
  
  if(S.at(K-1) == 'A') S.at(K-1) = 'a';
  if(S.at(K-1) == 'B') S.at(K-1) = 'b';
  if(S.at(K-1) == 'C') S.at(K-1) = 'c';
  
  cout << S << endl;
}

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

int T[86400*2];

int main(){
    int N;
    cin>>N;
    int t=0;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        t+=a;
        t%=86400;
        T[t]++;
        t+=b;
        t%=86400;
    }
    for(int i=0;i<86400;i++){
        T[i+86400]=T[i];
    }
    for(int i=1;i<86400*2;i++){
        T[i]+=T[i-1];
    }
    int ans=T[10800];
    for(int i=10801;i<86400*2;i++){
        ans=max(ans,T[i]-T[i-10801]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

int main(){
    int n;
    int c[1000],c2[1000],up[1000],btm[1000];
    int sum;
    sum = 0;
    cin>>n;
    for(int i = 0;i<n; i++){
        cin>>c[i];
        if(i == 0){
            up[i] = c[i];
        }else{
            up[i] = c[i] + up[i-1];
        }
    }
    for(int i =0; i<n; i++){
        cin>>c2[i];
        sum+=c2[i];
    }
    for(int i = 0; i<n;i++){
        if(i==0){
            btm[i] = sum;
        }else{
            btm[i] = btm[i-1] - c2[i-1];
        }
    }
    int ans;
    ans = 0;
    for(int i = 0; i<n; i++){
        int t;
        t = up[i] + btm[i];
        ans = max(ans, t);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
# ARC095D - Binomial Coefficients (ABC094D)
def main():
    # pascal's triangle := mid area (nCn/2) is the biggest
    N = int(input())
    A = tuple(map(int, input().split()))
    n = max(A)
    mid, r, cur = n / 2, -1, float("inf")
    for i in A:
        if i != n:
            x = abs(mid - i)
            if x < cur:
                r, cur = i, x
    print(n, r)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14556
from itertools import combinations

class Dice(object):

    def __init__(self, nums):
        self.nums = nums
        self.ifaces = [(1,2,3), (2,3,1), (3,1,2),
                       (1,4,2), (4,2,1), (2,1,4),
                       (1,5,4), (5,4,1), (4,1,5),
                       (1,3,5), (3,5,1), (5,1,3),
                       (2,6,3), (6,3,2), (3,2,6),
                       (2,4,6), (4,6,2), (6,2,4),
                       (4,5,6), (5,6,4), (6,4,5),
                       (3,6,5), (6,5,3), (5,3,6),]

    def index(self, num):
        return self.nums.index(num)

    def face(self, iface):
        return [self.nums[i-1] for i in iface]

    def all_face(self):
        for iface in self.ifaces:
            yield self.face(iface)

def is_same(d1, d2):
    for f1 in d1.all_face():
        found = False
        for f2 in d2.all_face():
            if f1 == f2:
                found = True
                break
        if not found:
            return False
    return True

n = int(input())

dices = []
for _ in range(n):
    dices.append(Dice([int(i) for i in input().split()]))

ans = True
for c in combinations(dices, 2):
    if is_same(c[0], c[1]):
        ans = False
        break
if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5712
// In God We Trust


# include <bits/stdc++.h>
using namespace std;

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second

signed main(){
  int n;
  cin >> n;
  int mod = 1e9 + 7;
  int a;
  int count[3];

  for (int i = 0 ; i < 3; i++)
    count[i] = 0;

  long long ans = 1;
  for (int i = 0; i < n; i++){
    cin >> a;
    int num = 0;
    for (int j = 0; j < 3; j++)
      if (count[j] == a)
	num ++;
    for (int j = 0; j < 3; j++)
      if (count[j] == a){
	count[j]++;
	break;
      }
    ans *= num;
    ans %= mod;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  int a[maxn];
  vector<int> V[maxn];
  int n;
  int m;
  void solve() {
    cin >> n;
    vector<int> b;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      b.push_back(a[i]);
    }
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    for (int i = 1; i <= n; ++i) {
      a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 2;
      m = max(a[i], m);
    }
    for (int i = 1; i < n; ++i) {
      int u, v;
      cin >> u >> v;
      V[u].push_back(v);
      V[v].push_back(u);
    }
    ans[1] = 1;
    upd(1, 1, m, a[1], 1);
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) {
      cout << ans[i] << '\n';
    }
  }
  int ans[maxn];
  void dfs(int u, int f) {
    for (int v : V[u]) {
      if (v == f)
        continue;
      int dpv = query(1, 1, m, 1, a[v] - 1) + 1;
      ans[v] = max(ans[u], dpv);
      int preval = query(1, 1, m, a[v], a[v]);
      upd(1, 1, m, a[v], max(preval, dpv));
      dfs(v, u);
      upd(1, 1, m, a[v], preval);
    }
  }
  int Max[maxn << 3];
  int query(int rt, int l, int r, int ll, int rr) {
    if (ll <= l && rr >= r)
      return Max[rt];
    int res = 0;
    int mid = l + r >> 1;
    if (ll <= mid)
      res = max(query(rt << 1, l, mid, ll, rr), res);
    if (rr > mid)
      res = max(res, query(rt << 1 | 1, mid + 1, r, ll, rr));
    return res;
  }
  void upd(int rt, int l, int r, int p, int v) {
    if (l == r) {
      Max[rt] = v;
      return;
    }
    int mid = l + r >> 1;
    if (p <= mid)
      upd(rt << 1, l, mid, p, v);
    else
      upd(rt << 1 | 1, mid + 1, r, p, v);
    Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]);
  }

} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

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

int gcd(int x, int y)
{
    if (y > x)
    {
        swap(x, y);
    }
    while (y > 0)
    {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3116
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int a,b;
	scanf("%d %d",&a,&b);
	int count=0;
	if (a>=b)
	{
		count=count+a;
		a=a-1;
	}else{
		count+=b;
		b--;
	}
	if (a>=b)
	{
		count=count+a;
		a=a-1;
	}else{
		count+=b;
		b--;
	}
	printf("%d\n",count);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void)
{
    string s;
    cin >> s;
    string day[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for (int i = 0; i < 7; i++) {
        if (s == day[i]) {
            cout << 7 - i << endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;
long dp[110][110][256] = {};

int main(){
	int n, k; cin >> n >> k;
	const int MOD = 1e9 + 7; dp[0][0][0] = 1;
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		
		for(int k = 0; k <= i; k++) for(int j = 0; j < 256; j++) dp[i + 1][k][j] = dp[i][k][j];
		for(int k = 0; k <= i; k++){
			for(int j = 0; j < 256; j++){
				(dp[i + 1][k + 1][j ^ a] += dp[i][k][j]) %= MOD;
			}
		}
	}
	
	long ans = 0;
	long fact[110] = {}; fact[0] = 1;
	for(int i = 0; i <= n; i++) fact[i + 1] = fact[i] * (i + 1) % MOD;
	for(int i = 0; i <= n; i++) (ans += dp[n][i][k] * fact[i]) %= MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 20864
n = int(input())
def CountingSort(A, B, k):
    C = [0] * (k + 1)
    for j in range(n):
        C[A[j]] += 1
    C[0] -= 1
    for i in range(1, k + 1):
        C[i] += C[i - 1]
    for j in A[::-1]:
        B[C[j]] = j
        C[j] -= 1
A = list(map(int, input().split()))
B = [0] * n
CountingSort(A, B, max(A))
print(*B)



Measured memory_bytes: 224376
// "header" {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,W;
    cin >> N >> W;
    vector<int> w(N+1),v(N+1);
    vector<vector<int> > dp(N+1,vector<int>(W+1));

    reps(i,N){
        cin >> w[i] >> v[i];
        reps(j,W){
            if(j - w[i] >= 0) dp[i][j] = max({dp[i-1][j-w[i]] + v[i],dp[i][j-1],dp[i-1][j]});
            else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
        }
    }

    cout << dp[N][W] << '\n';

    return 0;
}


Measured memory_bytes: 80256
/*  Author: Simanta Deb Turja 
    Website: https://simantaturja.github.io
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int k;
    cin >> k;
    int g = 0;
    for ( int i = 1; i <= k; ++i ) {
        for ( int j = 1; j <= k; ++j ) {
            for ( int l = 1; l <= k; ++l ) {
                g += __gcd(i, __gcd(j, l));
            }
        }
    }
    cout << g << endl;
    return 0;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(const string& init) : init(init) {}
  char getAnotherColor(char a, char b){
    if (a > b) swap(a, b);
    if (a == 'b'){
      if (b == 'g') return 'r';
      return 'g';
    }
    return 'b';
  }
  bool is_end(const string& s){
    for (int i = 1; i < s.size(); i++){
      if (s[0] != s[i]) return false;
    }
    return true;
  }

  int solve(){
    queue<string> Q;
    set<string> vis;
    int turn = 0;
    
    Q.push(init);
    vis.insert(init);
    while (!Q.empty()){
      queue<string> nQ;
      while (!Q.empty()){
        string state = Q.front();
        Q.pop();
        if (is_end(state)){
          return turn;
        }
        for (int i = 0; i < state.size() - 1; i++){
          if (state[i] != state[i + 1]){
            char another = getAnotherColor(state[i], state[i + 1]);
            string next_state = state;
            next_state[i + 1] = next_state[i] = another;
            if (vis.find(next_state) != vis.end()) continue;
            vis.insert(next_state);
            nQ.push(next_state);
          }
        }
      }
      turn++;
      swap(Q, nQ);
    }
    return -1;
  }
  string init;
};

int main()
{
  string s;
  while (cin >> s, s != "0"){
    Solver solver(s);
    int turn = solver.solve();
    if (turn == -1) puts("NA");
    else printf("%d\n", turn);
  }
  return 0;
}

Measured memory_bytes: 2692
#include<stdio.h>
#include<queue>
using namespace std;
int main(){
    int m,n,p,sum=0;
    priority_queue<int,
    vector<int>,
    greater<int>
    >que; 
    scanf("%d %d",&m,&n);
    for(int i=0;i<m;i++){
        scanf("%d",&p);
        que.push(p);
    }
    for(int i=0;i<n;i++){
        sum += que.top();
        que.pop();
    }
    printf("%d\n",sum);


}

Measured memory_bytes: 3144
import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
	
		while(sc.hasNextInt()){
			int value = sc.nextInt();
			if(value != 0){
				culc(value);
			}
			else{
				break;
			}
		}
	}
	public void culc(int value){
		ArrayList<Integer> n = new ArrayList<Integer>();
		for(int i = 0; i < value; i++){
			n.add(sc.nextInt());
		}
		Collections.sort(n);
		n.remove(value-1);
		n.remove(0);
		int sum = 0;
		for(int i = 0; i < n.size(); i++){
			sum = sum + n.get(i);
		}
		System.out.println(sum/n.size());
	}
	public static void main(String[] args){
		new Main().run();
	}
}

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


}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		System.out.println("" + s.charAt(0) + (s.length()-2) + s.charAt(s.length()-1));
	}
	static class Scanner{
		StringTokenizer st;BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public String next() throws IOException 
		{while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public boolean ready() throws IOException {return br.ready();}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int,int>

const int N = 1e5 + 1000;

vector<int> par(N, -1);

int root(int v) { return par[v] < 0 ? v : (par[v] = root(par[v])); }

void merge(int a, int b)
{
    if ((a = root(a)) == (b = root(b)))
        return;
    if (par[b] < par[a])
        swap(a, b);
    par[a] += par[b];
    par[b] = a;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    pii a[n];
    map<int, vector<int>> mpx, mpy;
    for(int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
        mpx[a[i].fi].push_back(i);
        mpy[a[i].se].push_back(i);
    }
    for(auto &el : mpx) {
        vector<int> v = el.se;
        for(int i = 0; i < sz(v) - 1; i++) {
            merge(v[i], v[i + 1]);
        }
    }
    for(auto &el : mpy) {
        vector<int> v = el.se;
        for(int i = 0; i < sz(v) - 1; i++) {
            merge(v[i], v[i + 1]);
        }
    }
    map<int, vector<pii>> mp;
    for(int i = 0; i < n; i++) {
        mp[root(i)].push_back(a[i]);
    }
    int ans = 0;
    for(auto &el : mp) {
        vector<pii> v = el.se;
        set<int> st1, st2;
        for(int i = 0; i < sz(v) ;i++) {
            st1.insert(v[i].fi);
            st2.insert(v[i].se);
        }
        ans += sz(st1) * sz(st2);
    }
    ans -= n;
    cout << ans << "\n";
}

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

int main(void) {
    int N,K;
    int mindiff = 0;
    int d;
    cin >> N >> K;

    vector<int> h(N);
    vector<int> diff(N-1);
    for(int i=0;i<N;i++) {
        cin >> h[i];
    }

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

    for(int i=1;i<N;i++) {
        diff[i-1] = h[i]-h[i-1];
    }

    for(int i=0;i<(K-1);i++) {
        mindiff += diff[i];
    }
//printf("cur:%d\n", mindiff);

    d = mindiff;
    for(int i=(K-1);i<diff.size();i++) {
        d += diff[i];
        d -= diff[i-(K-1)];
//printf("i:%d %d\n", i, d);
        if(mindiff > d) {
            mindiff = d;
        }
    }
    
    cout << mindiff << endl;

    return 0;
}


Measured memory_bytes: 1024
t = int(input())
query = [tuple(map(int, input().split())) for _ in range(t)]
def gcd(x, y):
    if y == 0: return x
    return gcd(y, x % y)
for a, b, c, d in query:
    g = gcd(b, d)
    r = a % g
    m = ((c - r)//g + 1) * g
    if b <= m and b <= a and b <= d: print('Yes')
    else: print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
map<ll,int> cnt;
ll ans=0;
int n,a[N];
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    ll sum=0;
    cnt[0]=1;
    for(int i=1;i<=n;i++) {
        sum+=a[i];
        ans+=cnt[sum];
        ++cnt[sum];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
#define size size()

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(a>=b){
        cout << "delicious" << endl;
    }else if(b-a<=x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    
    return 0;
}







Measured memory_bytes: 768
fun main(args: Array<String>) {
    var scoreA = 0
    var scoreB = 0
    val turnNum = readLine()!!.toInt()
    (0 until turnNum).forEach {
        val (cardA, cardB) = readLine()!!.split(" ")
        when {
            cardA == cardB -> {scoreA++; scoreB++}
            cardA > cardB -> scoreA += 3
            else -> scoreB += 3
        }
    }
    println("$scoreA $scoreB")
}



Measured memory_bytes: 32392
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
struct perm {
private:
	int sz;
	vector<long long> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		for(int i=1;i<=sz - 1;i++) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		for(int i=sz-2;i>=0;i--) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 18);
int main(){
	int n,k; cin >>n>>k;
	for(int i=1;i<=k;i++){
		ll ans=0;
		for(int j=0;j<=n-k-i+1;j++){
			ans+=p.comb(k-i+i-1,i-1)%mod*p.comb(n-k-j-i+1+i-1,i-1)%mod;
		}
		cout << ans%mod << endl;
	}
}

Measured memory_bytes: 4352
#include<cstdio>
using namespace std;
int n,x,su,ma;
int main(){
    scanf("%d",&n);
    su=ma=0;
    for(register int i=0;i<n;++i){
        scanf("%d",&x);
        if(x<=ma){
            su=su+x;
        }else{
            su=su+ma;
            ma=x;
        }
    }
    if(ma>=su)printf("No");
    else printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
ll fac[2005];
ll rfac[2005];

ll P(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;

    a = a * a % mod;
    x >>= 1;
  }

  return res;
}

int main() {
  ll n,k;

  cin >> n >> k;
  fac[0] = 1;
  rfac[0] = 1;
  for(ll i = 1; i <= n; i++) fac[i] = fac[i-1] * i % mod;
  for(ll i = 1; i <= n; i++) rfac[i] = P(fac[i],mod - 2);

  for(ll i = 1; i <= k; i++) {
    /*   cout << fac[n-k+i] << endl;
    cout << rfac[i] << endl;
    cout << rfac[n-k+1-i] << endl;
    cout << fac[k-1] << endl;
    cout << rfac[k-i] << endl;
    cout << rfac[i-1] << endl;
    */
    if(n - k + 1 - i < 0) cout << 0 << endl;
    else {cout << fac[n-k+1] * rfac[i] % mod * rfac[n-k+1-i] % mod * fac[k-1] % mod * rfac[k-i] % mod * rfac[i-1] % mod << endl;
    }
  }
}
  

  
  


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

#define TOU 4
#define KAI 3
#define HEYA 10

using namespace std;

int main(void){

	int n;
	int b,f,r,v;
	int house[TOU+1][KAI+1][HEYA+1]={0};

	cin>>n;

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

	for(int i=1;i<=TOU;i++){
		for(int j=1;j<=KAI;j++){
			for(int k=1;k<=HEYA;k++){
				cout<<" "<<house[i][j][k];
			}
			cout<<endl;
		}
		if(i!=TOU) cout<<"####################"<<endl;
	}

	return 0;
}

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

int main() {
    lint a,b,c,d; cin >> a >> b >> c >> d;
    lint ans = -9000000000000000000;
    bool xzero = false;
    bool yzero = false;
    if (a<=0 && b>=0) ans = 0;
    if (c<=0 && d>=0) ans = 0;
    ans = max({ans, a*c, a*d, b*c, b*d});
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    for(ll n; cin >> n, n; ){
        vector<ll>vec(n);
        ll sum = 0;
        for(ll i = 0; i < n; i++){
            cin >> vec[i];
            sum += vec[i];
        }
        ll ans = 0;
        for(ll i = 0; i < n; i++){
            if(vec[i] * n <= sum)ans++;
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

//マンハッタン距離
ll mandis(Pair a,Pair b){
    return abs(a.first-b.first)+abs(a.second-b.second);
}

void solve(){
    ll x;
    cin >> x;
    ll a=100;
    ll ans=0;
    while(a<x){
        a+=a/100;
        ans++;
    }
    kaku(ans);
}


int main(){
    solve();
}

Measured memory_bytes: 3632