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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,k;

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

    int d = 1;
    rep(i,0,n){
        if(d*2 < d+k)d*=2;
        else d += k;
    }
    P(d);
	return  0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = a.clone();
        Arrays.sort(b);
        if(b[n-1] == b[n-2]){
            for (int i = 0; i < n; i++) {
                System.out.println(b[n-1]);
            }
        } else {
            for (int i = 0; i < n; i++) {
                if(a[i] != b[n-1]){
                    System.out.println(b[n-1]);
                } else {
                    System.out.println(b[n-2]);
                }
            }
        }
        sc.close();
    }
}


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

using namespace std;
int r, c;
int Osenbei[10][10000];
int sum = 0;

void dfs(int roral) {
	if (roral == r) {
		int result = 0;
		for (int j = 0; j < c; ++j) {
			int num = 0;
			for (int i = 0; i < r; ++i) {
				if (Osenbei[i][j])
					++num;
			}
			result += max(num, r - num);
		}
		sum = max(result, sum);
		return;
	}
	dfs(roral + 1);

	
	for (int j = 0; j < c; ++j) {
		Osenbei[roral][j] = 1 - Osenbei[roral][j];
	}

	dfs(roral + 1);

	for (int j = 0; j < c; ++j) {
		Osenbei[roral][j] = 1 - Osenbei[roral][j];
	}


	return;
}

int  main() {
	while (true) {
		cin >> r >> c;
		if (c == 0) {
			break;
		}
		for (int i = 0; i < r; ++i) {
			for (int j = 0; j < c; ++j)
			{
				cin >> Osenbei[i][j];
			}
		}
		dfs(0);
		cout << sum << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);

int main() {
  ll N, M;
  cin >> N >> M;

  vi A(M);
  for (ll i = 0; i < M; i++) {
    cin >> A[i];
  }

  unordered_map<ll, ll> m;
  for (auto i: A) {
    ll j;
    if (i == 1) j = 2;
    else if (i == 2) j = 5;
    else if (i == 3) j = 5;
    else if (i == 4) j = 4;
    else if (i == 5) j = 5;
    else if (i == 6) j = 6;
    else if (i == 7) j = 3;
    else if (i == 8) j = 7;
    else if (i == 9) j = 6;
    m[j] = max(m[j], i);
  }

  vi dp(N + 1, -INF);

  dp[0] = 0;
  for (ll i = 1; i <= N; i++) {
    for (auto p: m) {
      if (i - p.first >= 0) {
        dp[i] = max(dp[i], dp[i - p.first] + 1);
      }
    }
  }


  while (N) {
    pii i = make_pair(-1, -1);
    for (auto p: m) {
      if (N - p.first >= 0 && dp[N - p.first] == dp[N] - 1) {
        if (i.second < p.second) {
          i = p;
        }
      }
    }
    cout << i.second;
    N -= i.first;
  }
  cout << endl;
}

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

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

struct edge{ int from, to, cost; };


int n, m;
bool used[20005];

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

int main()
{
	while (cin >> n >> m, n)
	{
		edge es[20005];
		REP(i, m)
		{
			int a, b, c;
			cin >> a >> b >> c;
			c--; b--;
			es[i] = edge{ b, c, a };
		}
		sort(es, es + m, comp);
		memset(used, false, sizeof(used));
		used[0] = true;
		REP(i, m)
		{
			if (used[es[i].from]) used[es[i].to] = true;
		}
		int cnt = 0;
		REP(i, n)
		{
			if (used[i]) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        long k = sc.nextLong();
        double ans = 0.0;
        if (n >= k) {
            ans += (n - k + 1) / (double) n;
        }
        for (long i = 1; i <= Math.min(n, k - 1); i++) {
            long x = k;
            double cnt = 0;
            long num = i * 2;
            while (x > num) {
                cnt++;
                num *= 2;
            }
            cnt++;
            // System.out.println("i = " + i);
            // System.out.println(cnt);
            // System.out.println(Math.pow(0.5, cnt));
            // System.out.println((double) (1.0 / (double) n));
            ans += Math.pow(0.5, cnt) * (double) (1.0 / (double) n);
        }
        System.out.printf("%.9f%n", ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename T>
struct Binary_Indexed_Tree{
    vector<T> bit;
    
    Binary_Indexed_Tree(int N){
        bit.assign(N+1, 0);
    }
    
    void add(int i, const T &x){
        for(i++; i < sz(bit); i += (i & -i)) bit[i] += x;
    }
    
    T sum(int i){
        T ret = 0;
        for(; i > 0; i -= (i & -i)) ret += bit[i];
        return ret;
    }
    
    T query(int l, int r){
        return sum(r) - sum(l);
    }
    
    void clear(){
        fill(bit.begin(), bit.end(), 0);
    }
};

int main(){
    string S;
    cin >> S;
    int N = sz(S);
    vector<int> ids[26];
    rep(i, N) ids[S[i]-'a'].pb(i);
    int a = 0;
    rep(i, 26) a += sz(ids[i])&1;
    if(a > 1) {cout << -1 << endl; return 0;}
    int cnt[26];
    fill(cnt, cnt+26, 0);
    int p[N];
    int now = 0;
    rep(i, N){
        int x = S[i]-'a';
        if(cnt[x]++ < sz(ids[x])/2) p[i] = now++;
    }
    rep(i, 26){
        int n = cnt[i];
        if(n&1) p[ids[i][(n-1)/2]] = (N-1)/2;
        rep(j, n) p[ids[i][n-1-j]] = N-1-p[ids[i][j]];
    }
    Binary_Indexed_Tree<int> bit(N);
    ll ans = 0;
    rep(i, N){
        ans += bit.query(p[i]+1, N);
        bit.add(p[i], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(ll i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,c=0,c1,c2,num,j=1;

    cin>>n>>k;
    vector<ll> v(n),vis(n+1,0),a,count(n+1,0);

    fori(i,0,n-1) cin>>v[i];

    a.pb(1); vis[1]=1;

    for(ll i=1;1;i++)
	{	num=v[j-1];
		c++;
		if(vis[num]==1)
		{	c1=count[num];
			c2=c;
			break;
		}
		j=num;
		count[num]=c;
		vis[num]=1;
		a.pb(num);
	}
	if(k<a.size())
		cout<<a[k];
	else
	{
		k=k-c1;
		ll l=c2-c1;
		k=k%l;
		k=k+c1;
		cout<<a[k];
	}
    return 0;
}


Measured memory_bytes: 9920
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n 

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

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

	ini(n); ini(i);
	outn(n - i + 1);
		
	return 0;
}


Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()] + [0]
ans = 0
i = 0
while(1):
    if (i == N): break
    if (H[i] == 0): 
        i += 1
        continue
    j = i + 1
    m = H[i]
    while(1):
        if (H[j] == 0): break
        m = min(m, H[j])
        j += 1
    ans += m
    for k in range(i, j):
        H[k] -= m
print(ans)


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

int main(){
  string s;
  cin >> s;
  int n = s.size();

  int cnt = 0;
  rep(i,n) if(s[i] == 'o') cnt++;
  if(cnt+15-n>=8) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[30];
ll c[30],s[400][30];
std::vector<P> v;

int main(void){
	int d,i,j,n=26;
	ll ansm = -INFLL;
	std::cin >> d;
	for(i=0; i<n; ++i){
		l[i] = -1;
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			v.push_back(P(s[i][j]+c[j]*(i-l[j]),j+1));
		}
		std::sort(v.begin(),v.end(),std::greater<P>());
		std::cout << v[0].second << std::endl;
		l[v[0].second-1] = i;
		v.clear();
	}
	return 0;
}


Measured memory_bytes: 3712
import sys
n,k=map(int,input().split())
# k=2
l=list(map(int,input().split()))
ans=[0,abs(l[1]-l[0])]
for i in range(2,n):
    m=sys.maxsize
    c=1
    while c<min(k+1,i+1):
        
        m=min(abs(l[i]-l[i-c])+ans[-c],m)
        c+=1
    ans.append(m)
# print(ans)
print(ans[-1])
    

Measured memory_bytes: 58080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 2000
#define MOD 1000000007
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
inline int fxp(int s, int n=MOD-2){int a=1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
struct Edge{int u,v,w;}e[MAXN+5]; inline bool operator < (Edge a, Edge b){return a.w<b.w;}
int fa[MAXN+5], n, m, L, M, R; ll X, W, C, del[MAXN+5];
inline int getf(int x){return x^fa[x]?fa[x]=getf(fa[x]):x;} inline bool Union(int x, int y){return (x=getf(x))^(y=getf(y))?fa[x]=y,true:false;}
ll Kruskal(int c=n-1){for(rint i = 1; i <= m && Union(e[i].u,e[i].v)?C+=e[i].w,--c:true; i++); return C;}
int main()
{
	n = read(), m = read(), X = read(); for(rint i = 1; i <= m; e[i].u = read(), e[i].v = read(), e[i].w = read(), i++); sort(e+1,e+m+1);
	for(rint i = 1; i <= n; fa[i] = i, i++); W = Kruskal(); if(W>X) return puts("0"),0;
	for(rint i = 1, j; i <= m; Union(e[i].u,e[i].v), C = e[i].w, Kruskal(n-2), del[i] = C-W, i++) for(j = 1; j <= n; fa[j] = j, j++);
	for(rint i = 1; i <= m; L += del[i]<X-W, M += del[i]==X-W, i++); R = m-L-M; printf("%d\n",(1ll+!!L)*fxp(2,R)*(fxp(2,M)+MOD-1-!L)%MOD); return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << "\n";
    return 0;
}

Measured memory_bytes: 256
class abc_152:
    
    def __init__(self):
        pass
    def A(self):
        pass
    def B(self):
        pass
    def C(self):
        N=int(input())
        P=list(map(int,input().split()))
        ans_count=0
        min_p=P[0]
        
        for i in range(N):
            if P[i]<=min_p:
                ans_count+=1
                min_p=P[i]
            else:continue
        print(ans_count)
        
    def D(self):
        pass
    def E(self):
        pass
    def F(self):
        pass
    
if __name__=='__main__':
    obj=abc_152()
    obj.C()

Measured memory_bytes: 75600
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main()
{
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static List<int[]>[] node;
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			int m = sc.nextInt();
			node=new List[n];
			for(int i=0;i<n;i++){
				node[i]=new ArrayList<int[]>();
			}
			if(n+m==0)break;
			for(int i=0;i<n;i++){
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				int cost = sc.nextInt();
				int time = sc.nextInt();
				node[a].add(new int[]{b,cost,time});
				node[b].add(new int[]{a,cost,time});
			}
			int k = sc.nextInt();
			for(int i=0;i<k;i++){
				int p = sc.nextInt()-1;
				int q = sc.nextInt()-1;
				int r = sc.nextInt()+1;
				System.out.println(min(p,q,r));
			}
		}
		sc.close();
	}
	static int min(int p,int q,int r){
		PriorityQueue<int[]>que=new PriorityQueue<int[]>(100,new Comparator<int[]>(){
			@Override
			public int compare(int[] arg0, int[] arg1) {
				return arg0[1]-arg1[1];
			}
		});
		int[] min = new int[node.length];
		Arrays.fill(min, 1<<30);
		min[p]=0;
		que.add(new int[]{p,0});
		while(!que.isEmpty()){
			int s = que.peek()[0];
			int cost=que.poll()[1];
			for(int[] a:node[s]){
				int next=a[0];
				int ncost=cost+a[r];
				if(min[next]>ncost){
					min[next]=ncost;
					que.add(new int[]{next,ncost});
				}
			}
		}
		return min[q];
	}
}

Measured memory_bytes: 95692
import math
n = int(input())
pi = math.acos(-1)
th = pi/3


class point:
    def __init__(self, x, y):
        self.x = x
        self.y = y


def koch(n, a, b):
        if n == 0:
            return 0
        s = point((2*a.x+1*b.x)/3, (2*a.y+1*b.y)/3)
        t = point((1*a.x+2*b.x)/3, (1*a.y+2*b.y)/3)
        u = point((t.x-s.x)*math.cos(th)
                  - (t.y-s.y)*math.sin(th)+s.x,
                  (t.x-s.x)*math.sin(th)+(t.y-s.y)*math.cos(th)+s.y)
        koch(n-1, a, s)
        print("{:.8f} {:.8f}".format(s.x, s.y))
        koch(n-1, s, u)
        print("{:.8f} {:.8f}".format(u.x, u.y))
        koch(n-1, u, t)
        print("{:.8f} {:.8f}".format(t.x, t.y))
        koch(n-1, t, b)


a = point(round(0, 8), round(0, 8))
b = point(round(100, 8), round(0, 8))
print("{:.8f} {:.8f}".format(a.x, a.y))
koch(n, a, b)
print("{:.8f} {:.8f}".format(b.x, b.y))



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

int main() {
	long int x,a,b,c,count=0,i,j,k;
	cin>>a>>b>>c>>x;
	for(i=0;i<=a;i++)
	  {
	      for(j=0;j<=b;j++)
	        {
	        	for(k=0;k<=c;k++)
	        	  {
	        	     if(10*i+2*j+k==(x/50))
	        	       ++count;
	        	  }
	        }
	  }
	cout<<count<<"\n";  
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,M;cin>>N>>M;
  int p=1;
  FOR(i,0,M)p*=2;
  cout<<(ll)(1900*M+(N-M)*100)*p<<endl;
}

Measured memory_bytes: 256
N = int(input())
M1 = 0
M2 = 0
A = []
for a in range(N):
    a = int(input())
    A.append(a)
    if a > M2:
        if a > M1:
            M2 = M1
            M1 = a
        else:
            M2 = a

for a in A:
    if a == M1:
        print(M2)
    else:
        print(M1)



Measured memory_bytes: 12532
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  int m = 0;
  int tmp = 0;
  rep(i,n){
    if(a[i] == m+1){
      m++;
    }
  }
  if(m == 0) print(-1);
  else print(n - m);
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 n;
  std::cin >> n;
  std::vector<i64> v;
  tools::read(v, n);

  auto uniq_c_sort_k22nr = [&](const bool is_even) {
    std::unordered_map<i64, i64> uniq_c;
    for (i64 i = 0; i < n; ++i) {
      if (i % 2 == (is_even ? 1 : 0)) {
        ++uniq_c[v[i]];
      }
    }

    std::vector<std::pair<i64, i64>> result;
    result.reserve(uniq_c.size());
    std::copy(uniq_c.begin(), uniq_c.end(), std::back_inserter(result));
    std::sort(result.begin(), result.end(), [&is_even](const std::pair<i64, i64>& x, const std::pair<i64, i64>& y) {
      return x.second > y.second || (x.second == y.second && ((is_even && x.first < y.first) || (!is_even && x.first > y.first)));
    });
    return result;
  };

  const std::vector<std::pair<i64, i64>> odd_counts = uniq_c_sort_k22nr(false);
  const std::vector<std::pair<i64, i64>> even_counts = uniq_c_sort_k22nr(true);
  if (odd_counts[0].first == even_counts[0].first) {
    std::cout << std::min(
      (n / 2 - (odd_counts.size() > 1 ? odd_counts[1].second : 0)) + (n / 2 - even_counts[0].second),
      (n / 2 - odd_counts[0].second) + (n / 2 - (even_counts.size() > 1 ? even_counts[1].second : 0))
    ) << std::endl;
  } else {
    std::cout << ((n / 2 - odd_counts[0].second) + (n / 2 - even_counts[0].second)) << std::endl;
  }
  return 0;
}

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

int main(void)
{
	int i, n;
	long taka = 1, aoki = 1;
	long cuntt, cunta; 
	long t[1000], a[1000];
	
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%ld %ld", &t[i], &a[i]);
	
	for (i = 0; i < n; i++)
	{
		cuntt = taka / t[i];
		if (taka % t[i] != 0) cuntt++;
		cunta = aoki / a[i];
		if (aoki % a[i] != 0) cunta++;
	
		taka = ((cuntt <= cunta) ? cunta : cuntt) * t[i];
		aoki = ((cuntt <= cunta) ? cunta : cuntt) * a[i];
	}
	
	printf("%ld\n", taka + aoki);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define re register
#define ui unsigned int
#define ull unsigned long long
int a[200100],f[200100],q[200100],nm[200100],ta,n;
bool check(re int mid)
{
	ta=0;
	for(re int i=2;i<=n;i++)if(a[i]<=a[i-1])
	{
		if(mid==0)return 0;
		while(q[ta]>a[i])ta--;
		re int x=a[i];
		for(;x;x--)
		{
			if(!ta||q[ta]!=x){q[++ta]=x,nm[ta]=1;break;}
			else if(nm[ta]<mid){nm[ta]++;break;}
			else ta--;
		}
		//printf("***%d %d %d\n",i,x,ta);
		if(!x)return 0;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	f[0]=1e9;
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	re int l=0,r=n,mid;
	for(mid=(l+r)/2;l<r;mid=(l+r)/2)
	{
		//printf("**%d %d %d\n",l,r,mid);
		if(check(mid))r=mid;else l=mid+1;
	}
	printf("%d\n",l+1);
}

Measured memory_bytes: 1024
import numpy as np

N, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for _ in range(N)])
dp = np.zeros(W + 1, dtype="int64")

for w, v in wv:
    dp[W:w-1:-1] = np.maximum(dp[W:w-1:-1], dp[W-w::-1] + v)
    
print(dp[-1])

Measured memory_bytes: 15516
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int digit = 0;
            int num = i;
            while (num != 0) {
                num /= 10;
                digit++;
            }
            if (digit % 2 == 1) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
def read():
    N = int(input().strip())
    return N, 

def solve(N):
    x = 1
    for i in range(1, 10):
        for j in range(i, 10):
            if i * j == N:
                return 'Yes'
    return 'No'

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if (x == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1 << endl;
}

Measured memory_bytes: 3688
class Tree
	def initialize(i)
		@index = i
		@children = []
	end

	def compute_euler_index
		stack = [[self, 0]]
		@l = 0
		n = 0
		until stack.empty? do
			v, i = stack[-1]
			if i >= v.children.size
				v.r = (n += 1)
				stack.pop
				stack[-1][1] += 1 unless stack.empty?
				next
			end
			c = v.children[i]
			c.l = (n += 1)
			stack << [c, 0]
		end
	end

	def compute_depth
		stack = [[self, 0]]
		d = 0
		until stack.empty? do
			v, i = stack[-1]
			if i >= v.children.size
				v.depth = d
				d -= 1
				stack.pop
				stack[-1][1] += 1 unless stack.empty?
				next
			end
			c = v.children[i]
			stack << [c, 0]
			d += 1
		end
	end

	attr_accessor :index, :children, :l, :r, :depth
end

class SegTree
	def initialize(a, l = 0, r = a.size-1)
		@l = l
		@r = r
		if l == r
			@value = a[l]
		else
			c = (l + r) / 2
			@children = [SegTree.new(a, l, c), SegTree.new(a, c + 1, r)]	
		end
	end

	def update(marked, l = @l, r = @r)
		if @l == l && @r == r
			if @lazy
				@lazy = marked if marked.depth > @lazy.depth
			else
				@lazy = marked
			end
			return
		end

		force if @lazy
		if r <= @children[0].r
			@children[0].update(marked, l, r)
		elsif @children[1].l <= l
			@children[1].update(marked, l, r)
		else
			@children[0].update(marked, l, @children[0].r)
			@children[1].update(marked, @children[1].l, r)
		end
	end

	def query(i)
		force if @lazy
		if @l == @r && @l == i
			@value.index
		elsif i <= @children[0].r
			@children[0].query(i)
		else
			@children[1].query(i)
		end
	end

	def force
		if @l == @r
			@value = @lazy if @lazy.depth > @value.depth
		else
			@children.each {|c| c.update(@lazy)}
		end

		@lazy = nil
	end

	attr_reader :l, :r
end

loop do
	n, q = gets.split.map(&:to_i)		
	break if n == 0
	sum = 0
	nodes = (0..n).map{|i| Tree.new(i) }
	(n-1).times do |i|
		j = gets.to_i
		nodes[j].children << nodes[i+2]
	end
	nodes[1].compute_euler_index
	nodes[1].compute_depth

	seg = SegTree.new((0..2*n-1).map { nodes[1] })

	q.times do
		query, i = gets.chomp.split
		target = nodes[i.to_i]
		if query == ?Q
		 	sum += seg.query(target.l)
		else
			seg.update(target, target.l, target.r)
		end
	end
	puts sum
end

Measured memory_bytes: 188352
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
#define mod 2038077799
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],B[n];
    int dA[n],dB[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++)
    {
        dA[i] = A[(i+1)%n]^A[i];
        dB[i] = B[(i+1)%n]^B[i];
    }
    int hashB=0;
    int base = 1400312813;
    for(int i=0;i<n;i++)
    {
        hashB*=base;
        hashB%=mod;
        hashB+=dB[i];
        hashB%=mod;
    }
    int hashA=0;
    for(int i=0;i<n;i++)
    {
        hashA*=base;
        hashA%=mod;
        hashA+=dA[i];
        hashA%=mod;
    }
    int exp = power(base,n-1,mod);
    vi ans;
    for(int i=0;i<n;i++)
    {
        if(hashA==hashB)
        ans.pb(i);

        int val = exp*dA[i];
        val%=mod;
        hashA+=mod - val;
        hashA%=mod;
        hashA*=base;
        hashA%=mod;
        hashA+=dA[i];
        hashA%=mod;
    }
    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" "<<(A[0]^B[(n-ans[i])%n])<<'\n';
    }
return 0;
}

Measured memory_bytes: 11704
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

string s;
int n;

void dfs(string &s, int t) {
	if (s.size() == n) {
		cout << s << endl;
		return;
	}

	for (int i = 0; i < t; i++) {
		s.push_back('a' + i);
		dfs(s, t);
		s.pop_back();
	}
	s.push_back('a' + t);
	dfs(s, t + 1);
	s.pop_back();
}

int main() {
	cin >> n;
	dfs(s, 0);
}

Measured memory_bytes: 1536
def grade(m, f, r):
    if m==-1 or f == -1:
        return 'F'
    if m+f >= 80:
        return 'A'
    if 65 <= m+f < 80:
        return 'B'
    if 50 <= m+f < 65:
        return 'C'
    if 30 <= m+f < 50:
        if r >= 50:
            return 'C'
        else:
            return 'D'
    if m+f < 30:
        return 'F'


while True:
    x = [int(x) for x in input().split()]
    m, f, r = x
    if m==-1 and f==-1 and r==-1:
        break
    print(grade(m, f, r))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
static const int MAX = 200000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R[MAX], n;
  cin >> n;
  for(int i = 0;i < n;i++) cin >> R[i];
  int maxv = -2000000000;
  int minv = R[0];

  for(int i = 1;i < n;i++) {
      maxv = max(maxv, R[i]-minv);
      minv = min(minv, R[i]);
  }
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <map>
#include <vector>
using namespace std;


int main(int argc, const char * argv[]) {
    int h,w;
    cin >> h >> w;
//    vector<vector<char>> p(h*w);
//    for(int i=0;i<w;i++){
//        for (int j=0; j<h; j++) {
//            cin >> p[i][j];
//        }
//    }
    vector<string> p(h);
    for (int i=0; i<h; i++) {
        cin >> p[i];
    }
    for(int i=0;i<w+2;i++){
        cout << "#";
    }
    cout << endl;
    for (int i=0; i<h; i++) {
        cout << "#";
        cout << p[i];
        cout << "#" << endl;
    }
    for(int i=0;i<w+2;i++){
        cout << "#";
    }
    return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;

    if (x == 11 || x == 2 || y == 2) cout << "No" << endl;
    else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
        cout << "Yes" << endl;
    }
    else if ((x == 4 || x == 6 || x == 9 ) && (y == 4 || y == 6 || y == 9 || y == 11)) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int a[n] = {0};

    for(int i = 0; i < 2 * m; i++){
        int x;  cin >> x;
        a[x - 1]++;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=2114;
struct edge{
	int to,rev;
	LL cap,cost;
	edge(int _to,int _cap,int _rev,int _cost){
		to=_to,cap=_cap,rev=_rev,cost=_cost;
	}
	edge(){
		;
	}
};
int src=2113,snk=2112;
vector<edge> G[Maxn];
int preve[Maxn],prevv[Maxn];
LL dist[Maxn];
int q[Maxn*Maxn],sq,eq,In[Maxn];
void add_edge(int u,int v,LL ca,LL co){
	G[u].pb(edge(v,ca,G[v].size(),co));
	G[v].pb(edge(u,0,G[u].size()-1,-co));
}
LL MCF(){
	LL ret=0;
	while (1){
		sq=eq=0;
		for (int i=0;i<Maxn;i++) dist[i]=1e18;
		dist[src]=0;
		q[eq++]=src;
		while (sq<eq){
			int x=q[sq++];In[x]=0;
			for (int i=0;i<G[x].size();i++){
				if (G[x][i].cap){
					int v=G[x][i].to;
					if (dist[v]>dist[x]+G[x][i].cost){
						dist[v]=dist[x]+G[x][i].cost;
						prevv[v]=x;preve[v]=i;
						if (!In[v]) q[eq++]=v,In[v]=1;
					}
				}
			}
		}
		if (dist[snk]==1e18){
			break;
		}
		LL fl=1e9;
		for (int i=snk;i!=src;i=prevv[i]){
			fl=min(fl,G[prevv[i]][preve[i]].cap);
		}
		ret+=1ll*fl*dist[snk];
		for (int i=snk;i!=src;i=prevv[i]){
			edge &E=G[prevv[i]][preve[i]];
			E.cap-=fl;
			G[i][E.rev].cap+=fl; 
		}
	}
	return ret;
}
int n;
int x[Maxn],y[Maxn],c[Maxn];
int _0=2020,_1=2021,_2=2022,_3=2023;
int __0=2010,__1=2011,__2=2012,__3=2013;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d %d %d",&x[i],&y[i],&c[i]);
		add_edge(src,i,c[i],0);
		add_edge(i,_0,c[i],-(x[i]+y[i]));
		add_edge(i,_1,c[i],-(x[i]-y[i]));
		add_edge(i,_2,c[i],-(y[i]-x[i]));
		add_edge(i,_3,c[i],-(-x[i]-y[i]));
	}
	for (int i=1;i<=n;i++){
		scanf("%d %d %d",&x[i],&y[i],&c[i]);
		add_edge(i+n,snk,c[i],0);
		add_edge(__0,i+n,c[i],-(x[i]+y[i]));
		add_edge(__1,i+n,c[i],-(x[i]-y[i]));
		add_edge(__2,i+n,c[i],-(y[i]-x[i]));
		add_edge(__3,i+n,c[i],-(-x[i]-y[i]));
	}
	add_edge(_0,__3,1e9,0);
	add_edge(_1,__2,1e9,0); 
	add_edge(_2,__1,1e9,0);
	add_edge(_3,__0,1e9,0);
	LL ans=MCF();
	printf("%lld\n",-ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int D;
    cin >> D;
    if(D==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    else if(D==23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if(D==24){
        cout << "Christmas Eve" << endl;
    }
    else{
        cout << "Christmas" << endl;
    }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

bool check(string s) {
    int n = s.size();
    if (n % 2 == 1) return false;
    return (s.substr(0, n / 2) == s.substr(n / 2));
}

int main() {
    string s; cin >> s;
    int n = s.size();
    per(i,n,i) {
        if (check(s.substr(0, i))) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;
int n, a[2000];
int ans;
void bad() {
    cout << "No\n";
}
void ok() {
    cout << "Yes\n";
}
int main() {
    ios_base::sync_with_stdio(0);
    int T;
    cin >> T;
    for (; T >= 1; T--) {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        if (a < b) bad();
        else
        if (d < b) bad();
        else
        if (c >= b - 1) ok();
        else {
            long long x = a % b;
            //[c + 1, b - 1]
            if (x >= c + 1) bad();
            else {
                long long g = __gcd(d, b);
                long long t = c + 1 - x;
                long long k = t / g;
                if (t % g != 0) k++;
                if (x + g * k < b) bad();
                else ok();
            }
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
int c[105][105];
int a[10005],n,m,k;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
inline void dfs(int x,int y,int dp,int gs){
	if(dp==k){
		int i,j;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++) cout<<c[i][j]<<" ";
			cout<<endl;
		}
		exit(0);
	}
	if(x<0||y<0||x==n||y==m) return;
	if(c[x][y]!=0) return;
	c[x][y]=dp+1;
	int ndp,ngs;
	ndp=dp;
	ngs=gs+1;
	if(ngs==a[dp]){
		ngs=0;
		ndp++;
	}
	for(int i=0;i<4;i++){
		dfs(x+dx[i],y+dy[i],ndp,ngs);
	}
	c[x][y]=0;
}
int main(){
	ios_base::sync_with_stdio(false);
	int i,j;
	cin>>n>>m;
	cin>>k;
	for(i=0;i<k;i++) cin>>a[i];
	dfs(0,0,0,0);
	return 0;
}



Measured memory_bytes: 896
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i128
    };

    let mut x = n + 1;
    let mut base = 0;
    let mut sum = 0;
    while x > 0 {
        let mut y = n / (base + 1);
        if y * (base + 1) >= n {
            y -= 1;
        }
        if x != n + 1 {
            sum += (x - y) * base;
        }

        base += 1;
        x = y;
    }

    println!("{}", sum);
}


Measured memory_bytes: 2196
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	long long A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max({ A * C, A * D, C * B, B * D }) << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n), res(n, 0);
    cin >> arr[0] >> arr[1];
    res[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i < n; ++i) {
        cin >> arr[i];
        res[i] = min(res[i - 1] + abs(arr[i] - arr[i - 1]), res[i - 2] + abs(arr[i] - arr[i - 2]));
    }
    cout << res[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long int> v;
    long long int a[n];
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a[i] = x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int p = 0;
    if(n % 2 != 0){
        p = n /2  + 1 - 1;
    }else{
        p = n / 2;
    }
    
    
    for(int i = 0; i < n; i++){
        if(n % 2 != 0){
            if(a[i] < v[p]){
                cout << (v[p] + v[p + 1]) / 2 << "\n";
            }
            else if(a[i] == v[p]){
                cout << (v[p - 1] + v[p + 1]) / 2 << "\n";
            }
            else{
                cout << (v[p - 1] + v[p]) / 2 << "\n";
            }
        }
        else{
            if(a[i] < v[p]){
                cout << v[p] << "\n";
            }
            else if(a[i] == v[p]){
                cout << v[p - 1] << "\n";
            }
            else{
                cout << v[p - 1] << "\n";
            }
        }
    }
    
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5 + 5;
int n, h[maxn], a[maxn];

int32_t main(){
    cin >> n;
    h[0] = 0; a[0] = 0;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= n; i++) cin >> a[i];
    map<int, int> dp;
    for(int i = n; i >= 0; i--){
        auto it = dp.upper_bound(h[i]);
        int sum = a[i];
        if(it != dp.end())
            sum += it -> second;
        dp[h[i]] = sum;
        it = dp.find(h[i]);
        while(it != dp.begin() && prev(it) -> second <= sum)
            it = dp.erase(prev(it));
    }
    cout << dp[0] << "\n";
    return 0;
}

Measured memory_bytes: 19220
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cout << ", "; cetak(v...);}
 
#define debug(x...) cout << '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())


const int MOD = 1e9 + 7;

int add(int x, int y){
    int ret = x + y;
    if(ret >= MOD) ret -= MOD;
    return ret;
}
int sub(int x, int y){
    int ret = x - y;
    if(ret < 0) ret += MOD;
    return ret;
}
int mul(int x, int y){
    return (long long)x * y % MOD;
}


const int mx = 1e5 + 10;

void solve(){
    int h, w, n;
    cin >> h >> w >> n;
    if(h < w) swap(h, w);
    for(int i = 1; i <= w; i++){
        if(i * h >= n){
            cout << i << endl;
            return;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i, n) for (ll i = 0, i ## _end = n; i < i ## _end; i++)
#define ALL_OF(v) (v).begin(), (v).end()
#define REV_OF(v) (v).rbegin(), (v).rend()

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

        vector<ll> h(n+1);
        REP(i, n+1) cin >> h[i];
        
        REP(i, n+1) {

            vector<ll> h2 = h;
            h2.erase(h2.begin() + i);

            vector<ll> d(n-1);
            REP(i, n-1) d[i] = h2[i+1] - h2[i];

            bool is_same = true;
            REP(i, n-2) if (d[i] != d[i+1]) {
                is_same = false;
                break;
            }

            if (is_same) {
                cout << h[i] << endl;
                break;
            }
            
        }
    
    }

}


Measured memory_bytes: 3128
k = int(input())
a, b = map(int, input().split())

f = False
for i in range(1, 1001):
  t = i * k
  if a <= t and t <= b:
    f = True
    break
  if t > b:
    break

if f:
  print('OK')
else:
  print('NG')

Measured memory_bytes: 61608
import math
def till_sum(n):
    return((n) * (n - 1) / 2)
s = list(input())
count = 0
ls = []
for i in range(len(s)):
    count += 1
    if len(s) - 1 == i:
        break
    else:
        if s[i] != s[i+1]:
            ls.append(count)
            count = 0
ls.append(count)
result = sum(map(till_sum, ls))
if s[0] == "<":
    for i in range(math.ceil(len(ls)/2)):
        if len(ls) - 1 == 2*i:
            result += ls[2*i]
        else:
            if ls[2*i] < ls[2*i + 1]:
                result += ls[2*i + 1]
            if ls[2*i] >= ls[2*i + 1]:
                result += ls[2*i]
else:
    result += ls[0]
    ls = ls[1:]
    for i in range(math.ceil(len(ls)/2)):
        if len(ls) - 1 == 2*i:
            result += ls[2*i]
        else:
            if ls[2*i] < ls[2*i + 1]:
                result += ls[2*i + 1]
            if ls[2*i] >= ls[2*i + 1]:
                result += ls[2*i]
print(int(result))


Measured memory_bytes: 11696