akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
  int i,j,x;
  int N;
  scanf("%d",&N);
  
  int a[N+1];
  
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<N;i++){
    for(j=i;j<N;j++){
      if(a[j]<a[i]){
        x=a[i];
        a[i]=a[j];
        a[j]=x;
      }
      else{}
    }
  }
  
  printf("%d\n",a[N-1]-a[0]);
    
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int K, A, B;
    cin >> K >> A >> B;
    FOR(i, A, B + 1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        int ans = 0;

        if(S.equals("RRR")){
            ans =3;
        }else if(S.indexOf("R") == -1){
            ans = 0;
        }else{
            if(S.indexOf("RR") == -1){
                ans = 1;
            }else{
                ans = 2;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long W = sc.nextLong();
		long H = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		double a = W / 2;
		double b = H / 2;
		double X = 2.0 * a - x;
		double Y = 2.0 * b - y;
		
		int num = 0;
		if(2 * x == W && 2 * y == H) {
			num = 1;
		}
		
		double S = W * H / 2.0;
		
		System.out.println(S + " " + num);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
int n,m,a[105],ji;
int main()
{
    read(n);read(m);for(int i=1;i<=m;i++) read(a[i]),ji+=a[i]&1;
    if(ji>2) return puts("Impossible"),0;
    for(int i=2;i<m;i++) if(a[i]&1) if(a[1]&1) swap(a[i],a[m]);else swap(a[i],a[1]);
    if(m==1){print(a[1]);el();print(n==1?1:2);el();prints("1 ",0);if(n>1) print(n-1);flush();return 0;}
    for(int i=1;i<=m;i++) print(a[i]),sp();el();a[1]++;a[m]--;if(!a[m]) m--;
    print(m);el();for(int i=1;i<=m;i++) print(a[i]),sp();flush();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

int main()
{
	ll N,W;
	cin >> N >> W;
	ll w[N],val[N];
	
	for(ll i=0;i<N;i++)
	{
		cin >> w[i] >> val[i];
	}
	
	ll dp[W+5],dptemp[W+5];
	memset(dp,0,sizeof(dp));
	memset(dptemp,0,sizeof(dptemp));
	
	for(ll i=0;i<N;i++)
	{
		for(ll j=1;j<=W;j++)
		{
			dptemp[j]=dp[j];
			if(j>=w[i])
			{
				dptemp[j]=max(dp[j],val[i]+dp[j-w[i]]);
			}
		}
		for(ll j=1;j<=W;j++)
		{
			dp[j]=dptemp[j];
		}
	}
	
	cout << dp[W] << endl;
}

Measured memory_bytes: 1792
#selection sort???????????°??????

#Swap????????????
def Swap(a, b)
    return b, a
end

#SelectionSort????????????
def SelectionSort(a, length)
    count = 0
    for i in 0..length-1
        mini = i
        for j in i..length-1
            if a[j] < a[mini] then
                mini = j
            end
        end
        if i != mini then
            a[i], a[mini] = Swap(a[i], a[mini])
            count = count + 1
        end
    end
    return a, count
end

#SelectionSort??????????????¨?????????????????????
def PrintSelectionSortResult(a, length, count)
    i = -1
    for i in 0..length-2
        print a[i], " "
    end
    print a[i+1], "\n"
    print count, "\n"
end

#?????????????????°?????\?????????
length = readline.to_i

#??????????????\?????????
A = gets.chomp.split(" ").map(&:to_i)

B, count = SelectionSort(A, length)

PrintSelectionSortResult(B, length, count)

Measured memory_bytes: 8676
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
#include <functional>
using namespace std;

int main() {
	int n = 0;
	cin >> n;
	vector<int> counter(n, 0);
	for(int i = 0; i < n; i ++)
		cin >> counter[i];
	long ret = 0;
	for(int i = 0; i < n; i ++) {
		if(i > 0 && counter[i - 1] > 0 && counter[i] > 0) {
			ret ++;
			counter[i - 1] = 0;
			counter[i] --;
		}
		if(counter[i] >= 2) {
			ret = ret + counter[i] / 2;
			counter[i] = counter[i] % 2;
		}
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 640
import io.StdIn._
import math._

object Main extends App {
  val Array(n, k) = readLine() split(' ') map(_.toInt)
  val hs = readLine() split(' ') map(_.toInt)

  val dp = new Array[Long](n)
  dp(0) = 0

  for (i <- 1 until min(n,k)) {
    dp(i) = (1 to i).map(j => dp(i-j)+abs(hs(i)-hs(i-j))).min
  }

  if (k <= n)
  for (i <- k until n) {
    dp(i) = (1 to k).map(j => dp(i-j)+abs(hs(i)-hs(i-j))).min
  }

  println(dp.last)
}

Measured memory_bytes: 64188
#include <cstdio>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;

struct Board {
	char state[4][8];
	Board(){}
};

bool operator< (const Board& lhs, const Board& rhs) {
	return memcmp(&lhs, &rhs, sizeof(Board)) < 0;
}

int board[4][8];

void init() {
	memset(board, 0, sizeof(board));
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 7; ++j) {
			scanf("%d", board[i]+j+1);
		}
	}
}

int estimateBoard(const Board& x) {
	int ans = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 8; ++j) if (x.state[i][j] != -1) {
			if (!((x.state[i][j]>>3) == i && (x.state[i][j]&7) == j)) {
				++ans;
			}
		}
	}
	return ans;
}

int solve() {
	map<Board, int> estimate;
	
	priority_queue< pair<int, Board> > que;

	Board start;
	memset(&start.state, -1, 4*8);
	for (int i = 0; i < 4; ++i) {
		for (int j = 1; j < 8; ++j) {
			if (board[i][j]) {
				start.state[i][j] = ((board[i][j]/10 - 1)<<3) | (board[i][j]%10 - 1);
			}
			if ((start.state[i][j]&7) == 0) {
				swap(start.state[start.state[i][j]>>3][0], start.state[i][j]);
			}
		}
	}
	estimate[start] = estimateBoard(start);
	que.push(make_pair(-estimate[start], start));

	for (;!que.empty();) {
		int dist = -que.top().first;
		Board cur = que.top().second;
		que.pop();

		int esti = estimate[cur];
		if (esti == 0) {
			return dist;
		}
		dist -= esti;

		for (int i = 0; i < 4; ++i) {
			for (int j = 1; j < 8; ++j) if (cur.state[i][j] == -1) {
				char left = cur.state[i][j-1] + 1;
				for (int ii = 0; ii < 4; ++ii) {
					for (int jj = 1; jj < 8; ++jj) if (cur.state[ii][jj] == left) {
						swap(cur.state[ii][jj], cur.state[i][j]);
						if (estimate.find(cur) == estimate.end()) {
							estimate[cur] = estimateBoard(cur);
							int nd = dist + 1 + estimate[cur];
							que.push(make_pair(-nd, cur));
						}
						swap(cur.state[ii][jj], cur.state[i][j]);
					}
				}
			}
		}
	}

	return -1;
}

int main() {
	int T; scanf("%d", &T);
	for (int _ = 0; _ < T; ++_) {
		init();
		printf("%d\n", solve());
	}
	return 0;
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> L(n);
    for (int i = 0; i < n; i++)
    {
        cin >> L[i];
    }
    vector<int> d(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        d[i + 1] = d[i] + L[i];
    }

    int ans = 0;

    for (int i = 0; i < n + 1; i++)
    {
        if (d[i] <= x)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#ifdef LOCAL
  #include "debug.hpp"
#endif

double dp[3001][3005] = {};

int main(){
    int n;
    scanf("%d", &n);
    vector <double> p(n);
    for (int i = 0; i < n; i++) {
      scanf("%lf", &p[i]);
      dp[0][i] = (1-p[i]);
      if (i > 0) dp[0][i] *= (dp[0][i-1]);
    }
    dp[1][0] = p[0];
    for(int j = 1; j < n; j++) {
      for(int i = 1; i < n+1; i++) {
        dp[i][j] = p[j]*dp[i-1][j-1];
        dp[i][j] += (1-p[j])*dp[i][j-1];
      }
    }
    double sim = 0;
    for (int i = 0; i < n+1; i++) {
      if(i > (n)/2) sim += dp[i][n-1];
    }
    printf("%.10lf",sim);
#ifdef LOCAL
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 70656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

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

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

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N, K;
int dp[105][3][3]; // dp[?????\??????][?????\???????????\???][?????\???????????\???]
int menu[105];

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

    memset(menu, -1, sizeof menu);

    rep(i, K) {
        int a, b; cin >> a >> b;
        menu[a - 1] = b - 1;
    }

    dp[0][0][1] = 1;

    if (menu[0] != -1) {
        dp[1][menu[0]][!menu[0]] = 1;
    } else {
        rep(i, 3) {
            dp[1][i][!i] = 1;
        }
    }

    if (menu[1] != -1) {
        rep(i, 3) {
            rep(j, 3) {
                dp[2][menu[1]][i] += dp[1][i][j];
                dp[2][menu[1]][i] %= 10000;
            }
        }
    } else {
        rep(i, 3) rep(j, 3) {
            dp[2][i][j] += dp[1][j][!j];
            dp[2][i][j] %= 10000;
        }
    }

    for (int i = 2; i < N; ++i) {
        if (menu[i] != -1) {
            rep(j, 3) {
                rep(k, 3) {
                    if (menu[i] == j && j == k) continue;
                    dp[i + 1][menu[i]][j] += dp[i][j][k];
                    dp[i + 1][menu[i]][j] %= 10000;
                }
            }
        } else {
            rep(j, 3) {
                rep(k, 3) {
                    rep(l, 3) {
                        if (j == k && k == l) continue;
                        dp[i + 1][j][k] += dp[i][k][l];
                        dp[i + 1][j][k] %= 10000;
                    }
                }
            }
        }
    }

    int ans = 0;

    rep(i, 3) rep(j, 3) {
        ans += dp[N][i][j];
        ans %= 10000;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3068
{$asmmode intel}
var n:longint;
begin
  readln(n);
  asm
    mov eax,n;//将一个n挪入寄存器
    mov ebx,n;//将另一个n挪入寄存器
    mul ebx;  //执行乘法操作
    mov ebx,4;//把ebx设置为4
    div ebx;  //执行除法操作
    mov n,eax;//把计算结果返回n
  end;
  writeln(n);
end.

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, 
    dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

ll gcd(ll p, ll q){
    if(p%q==0)return q;
    else return gcd(q, p%q);
}

int main() {
    int T;
    cin >> T;
    REP(t,T){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        if(b > d || a < b){
            cout << "No" << endl;
            continue;
        }
        if (b <= c){
            cout << "Yes" << endl;
            continue;
        }
        ll g = gcd(b,d);
        a %= g;
        if(c%g < a || (b-c-1) >= g){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  
  char arr[3];
  cin >> arr;
  
  int cost = 700;
  
  for(int i = 0; i < 3; i ++){
  	if(arr[i] == 'o')
  		cost += 100;
  }
  
  cout << cost;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for(char& c : s) c -= '0';
    stack<char> st;
    int ans = 0;
    for(char c : s) {
        if(not st.empty() and st.top() != c) {
            st.pop();
            ans += 2;
        } else {
            st.push(c);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = max(b * c, max(a * d, max(b * d, a * c)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

const int N = 309;
const int mod = 1e9 + 7;
typedef long long int ll;	

int main () {
	int a,b,c,d,k;
	cin>>a>>b>>c>>d>>k;
	cout<< (c-a)*60 + (d-b) - k;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<stack>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	stack<char> st;
	rep(i,s.size()){
		if(s[i]=='B'){
			if(st.size()!=0)st.pop();
		}else st.push(s[i]);
	}
	vector<char> vec;
	while(!st.empty()){
		vec.push_back(st.top());
		st.pop();
	}
	for(int i=vec.size()-1;i>=0;i--)cout<<vec[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }

    int ans=1e9;
    for(int i=0;i<(1<<n);i++){
        int sum=0;
        bool flag=true;
        vector<int> v(n,0);
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                sum+=c[j];
                for(int k=0;k<m;k++){
                    v[k]+=a[j][k];
                }
            }
        }
        for(int l=0;l<m;l++){
            if(v[l]<x) flag=false;
        }
        if(flag) ans=min(ans,sum);
    }
    if(ans==1e9) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);
	
	
	int h,a;
	cin>>h>>a;

	float x = (float)h/ a;
	cout<<(ceil(x))<<endl; 


}

Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}

signed main(){
	int a,b,c,d,e;
	cin>>a>>c>>b>>d>>e;
	if(abs(a-b)<=(c-d)*e){
		puts("YES");
	}else{
		puts("NO");
	}
	return 0;
}

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

using namespace std;
using ll = long long;

class disjoint_set {
    std::vector<long long> parent, rank;

    public:
        std::vector<long long> set_size;
        disjoint_set();
        disjoint_set(long long size);

        void make_set(long long x);
        long long find_set(long long x);
        void unite(long long x, long long y);
        void resize(long long size);
};


disjoint_set::disjoint_set(long long size)
{
    parent.resize(size);
    rank.resize(size);
    set_size.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


disjoint_set::disjoint_set()
    : disjoint_set(0)
{
}


void disjoint_set::resize(long long size)
{
    parent.resize(size);
    rank.resize(size);
    set_size.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


void disjoint_set::make_set(long long x)
{
    parent[x] = x;
    rank[x] = 0;
    set_size[x] = 1;
}


long long disjoint_set::find_set(long long x)
{
    if (x != parent[x]) {
        parent[x] = find_set(parent[x]);
    }
    return parent[x];
}


void disjoint_set::unite(long long x, long long y)
{
    long long rx, ry;
    rx = find_set(x);
    ry = find_set(y);
    if (rx == ry)
        return;
    if (rank[rx] == rank[ry]) {
        parent[rx] = ry;
        // when the rank (height) of the trees are the same
        // uniting trees will increase the rank.
        rank[ry]++;
        set_size[ry] += set_size[rx];
    } else if (rank[rx] < rank[ry]) {
        // uniting a shorter tree under a higher tree
        // won't change the rank (height) of the united tree.
        parent[rx] = ry;
        set_size[ry] += set_size[rx];
    } else {
        parent[ry] = rx;
        set_size[rx] += set_size[ry];
    }
}



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

    disjoint_set ds(N);
    for (ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        A--; B--;

        ds.unite(A, B);
    }

    set<ll> roots;
    for (ll i = 0; i < N; i++) {
        ll r = ds.find_set(i);
        roots.emplace(r);
    }
    ll ans = 0;
    for (auto r : roots) {
        ans = max(ans, ds.set_size[r]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 17004
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    vector<char> d(n);
    
    i64 sum = 0;
    REP(i,n){
        if(i < k || t.at(i) != d.at(i-k)){
            d.at(i) = t.at(i);
            switch (t.at(i)){
            case 's':
                sum += r;
                break;
            case 'r':
                sum += p;
                break;
            case 'p':
                sum += s;
                break;
            }
        } else {
            d.at(i) = 'e';
            continue;
        }
        
    }

    cout<<sum<<endl;


    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;

char a[1000000];
int main(){
	ss(a);
	int lena = len(a);
	if(lena == 2){
		if(a[0] == a[1]){
			p(1) pk p(2) pn
		}else{
			puts("-1 -1");
		}
		return 0;
	}
	for(int i = 0; i <= lena-3; i ++){
		if(a[i] == a[i+1]){
			p(i+1) pk p(i+2) pn return 0;
		}else if(a[i] == a[i+2]){
			p(i+1) pk p(i+3) pn return 0;
		}
	}
	if(a[lena-1] == a[lena-2]){
		p(lena) pk p(lena+1) pn return 0;
	}
	puts("-1 -1");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s; cin >> s;
  int n = (int)s.size();
  if(n==2 && s[0]==s[1]){
    cout << "1 2" << endl;
    return 0;
  }
  rep(i,n-2){
    string ss = s.substr(i,3);
    sort(all(ss));
    if(ss[0] == ss[1] || ss[1] == ss[2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
var
 i,j:longint;
 st:string;
begin
  readln(st);
  for i:=1 to length(st) do
    begin
      if st[i]='C' then
        for j:=i+1 to length(st) do if st[j]='F' then begin writeln('Yes');exit;end;
    end;
  writeln('No');
end.

Measured memory_bytes: 128
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        print('#'*W)
        for i in range(1,H-1):
            print('#','.'*(W-2),'#', sep='')
        print('#'*W)
        print("\n", end="")


Measured memory_bytes: 5636
import sys
input = sys.stdin.readline

N = int(input())
C = input()

bad_w = 0
red = 0
ok = True
for i in range(N-1,-1,-1):
    if C[i] == 'R':
        red += 1
        ok = False
    if not ok and C[i] == 'W':
        bad_w += 1

good_red = 0
for i in range(red):
    if C[i] == 'R':
        good_red += 1


print( min(bad_w, N-bad_w, red-good_red) )


Measured memory_bytes: 67752
#include <iostream>
using namespace std;
int main() {
  int h,w; cin >> h >>w;
  for (int a=0;a<w+2;a++) {
    cout << "#";
  }
  cout << endl;
  for (int i=0;i<h;i++) {
    string s; cin >> s;
    cout << "#" << s << "#" << endl;
  }
  for (int b=0;b<w+2;b++) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int visit[101],d[101],f[101],t;
int n,M[101][101];
static const int WHITE=0;
static const int GRAY=1;

void dfs(int u){
  visit[u]=GRAY;
  d[u]=++t;
  for(int v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(visit[v]==WHITE) dfs(v);
  }
  f[u]=++t;
}

int main(){
  int u,v,k;
  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  
  for(int i=0;i<n;i++){
    if(visit[i]==WHITE) dfs(i);
  }

  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  for(int i=1;i<4;i++){
    if(s[i]==s[i-1]){
      cout<<"Bad"<<'\n';
      return 0;
    }
  }
  cout<<"Good"<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

int main() {
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int n;

void find_ans(string s, char mx) {
    string t = s;
    if(s.length() == n) {
        cout << t << endl;
        return;
    }
    else {
        for(char c = 'a'; c <= mx; c++) {
            if(c == mx) find_ans(s+c, char(mx+1));
            else find_ans(s+c, mx);
        }
    }
}

int main() {
    cin >> n;
    find_ans("", 'a');
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

static int n;
static vector<int> G[MAX];
static vector<int> B[MAX];
static int color[MAX];
static int color_num[MAX];

void dfs(int r, int c)
{
    stack<int> S;

    S.push(r);
    color[r] = c; color_num[c]++;
    while (!S.empty()) {
        int u = S.top(); S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c; color_num[c]++;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int i = 0; i < n; i++) color_num[i] = 0;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main()
{
    int i, j;
    int m, k;
    int s, t;

    cin >> n >> m >> k;

    for (i = 0; i < m; i++) {
        cin >> s >> t;
        G[s-1].push_back(t-1);
        G[t-1].push_back(s-1);
    }

    for (i = 0; i < k; i++) {
        cin >> s >> t;
        B[s-1].push_back(t-1);
        B[t-1].push_back(s-1);
    }

    assignColor();

    for (i = 0; i < n; i++) {
        int ans;

        if (i) cout << " ";
        /* cout << color_num[color[i]] << " " << 1 << " " << G[i].size() << " " << B[i].size() << endl;; */
        ans = color_num[color[i]] - 1 - G[i].size();
        for (j = 0; j < B[i].size(); j++) {
            if (color[B[i][j]] == color[i]) ans--;
        }
        cout << ans;
    }
    cout << endl;

    return 0;
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i,c = 1,cur;
    cin >> n;
    cur = 7%n;
    while(c <= n){
    	if(cur == 0){
    		cout << c << nl;
    		return;
    	}
    	cur = (cur*10+7)%n;
    	c++;
    }
    cout << -1 << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
char str[32][32];
struct dice{
	int b;
	int r,c;
	char t[6];
	dice(){
		r=0;c=0;b=0;
		t[0]='r';
		t[1]='c';
		t[2]='g';
		t[3]='m';
		t[4]='b';
		t[5]='y';
	}
};
inline bool operator<(const dice &a,const dice &b){
	if(a.b!=b.b)return a.b<b.b;
	if(a.r!=b.r)return a.r<b.r;
	if(a.c!=b.c)return a.c<b.c;
	for(int i=0;i<6;i++)if(a.t[i]!=b.t[i])return a.t[i]<b.t[i];
	return false;
}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void rot(dice &a,int b){
	if(b==0){
		char tmp=a.t[0];
		a.t[0]=a.t[5];
		a.t[5]=a.t[1];
		a.t[1]=a.t[4];
		a.t[4]=tmp;
	}
	if(b==1){
		char tmp=a.t[0];
		a.t[0]=a.t[2];
		a.t[2]=a.t[1];
		a.t[1]=a.t[3];
		a.t[3]=tmp;
	}
	if(b==2){
		char tmp=a.t[0];
		a.t[0]=a.t[4];
		a.t[4]=a.t[1];
		a.t[1]=a.t[5];
		a.t[5]=tmp;
	}
	if(b==3){
		char tmp=a.t[0];
		a.t[0]=a.t[3];
		a.t[3]=a.t[1];
		a.t[1]=a.t[2];
		a.t[2]=tmp;
	}
}
set<dice>S;
char com[7];
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a){
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		scanf("%s",com);
		S.clear();
		dice st;
		queue<pair<int,dice> >Q;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(str[i][j]=='#'){
					str[i][j]='w';
					st.r=i;st.c=j;
				}
			}
		}
		Q.push(make_pair(0,st));
		S.insert(st);
		int ret=-1;
		
		while(Q.size()){
			int cost=Q.front().first;
			dice at=Q.front().second;
	//		printf("%d %d %d: %d\n",at.r,at.c,at.b,cost);
			Q.pop();
			for(int i=0;i<4;i++){
				if(0>at.r+dx[i]||at.r+dx[i]>=a||0>at.c+dy[i]||at.c+dy[i]>=b)continue;
				if(str[at.r+dx[i]][at.c+dy[i]]=='k')continue;
				rot(at,i);
				if(str[at.r+dx[i]][at.c+dy[i]]=='w'||(str[at.r+dx[i]][at.c+dy[i]]==com[at.b]&&
				str[at.r+dx[i]][at.c+dy[i]]==at.t[0])){
					dice to=at;
					to.r+=dx[i];to.c+=dy[i];
					if(str[at.r+dx[i]][at.c+dy[i]]!='w'){
						to.b++;
					}
					if(to.b==6&&!~ret)ret=cost+1;
					if(to.b<6&&!S.count(to)){
						S.insert(to);
						Q.push(make_pair(cost+1,to));
						
					}
				}
				rot(at,i^2);
			}
		}
		if(!~ret)printf("unreachable\n");
		else printf("%d\n",ret);
	}
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}

signed main(){
    int n ; cin >> n ;
    v<int> a(n), b(n) ;
    for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
    for( int i = 0 ; i < n ; i++ ) cin >> b[i] ;
    shuffle( all(b), default_random_engine() ) ;
    int prev = -1, j = 0 ;
    for( int i = 0 ; i < n ; i++ ){
        if( a[i] != prev ) j = 0 ;
        if( a[i] == b[i] ){
            for( ; j < n ; j++ ){
                if( a[i] != b[j] && a[j] != b[i] ){
                    swap( b[i], b[j] ) ;
                    break ;
                }
            }
            if( a[i] == b[i] ) {
                cout << "No" ; return 0 ;
            }
        }
        prev = a[i] ;
    }
    cout << "Yes" << endl ;
    for( int i = 0 ; i < n ; i++ ) cout << b[i] << " " ;
    return 0 ;   
}          

Measured memory_bytes: 6424
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln((s[0] == s[$-1]) ^ (s.length%2 != 0) ? "First" : "Second");
}


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

int main()
{
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K)
    {
        cout << S << endl;
        return 0;
    }
    else
    {
        cout << S.substr(0, K).append("...") << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int r;
void input()
{
    cin>>r;
}

void solve()
{
    cout<<fixed<<setprecision(5)<<2*r*3.141592<<endl;
}

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

Measured memory_bytes: 3768
#!/usr/bin/env python
# -*- coding: utf-8 -*-


N,T = map(int,raw_input().split(" "))
t = map(int,raw_input().split(" "))
X = 0
sum = 0

if(N == 1):
	print T
else:
	for n in range(N-1):
		if(t[n+1]- t[n]<=T):
			X = t[n+1] + X - t[n]
		else:
			X = X + T

	X = X + T

	print X

Measured memory_bytes: 20036
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;
typedef long long i64;

int R[MAX_N], X, K, Q;

void get(i64 &temp) {
  if (temp < 0) temp = 0;
  if (temp > X) temp = X;
}

int main() {
  scanf("%d%d", &X, &K);
  for (int i = 1; i <= K; ++i)
    scanf("%d", &R[i]);

  scanf("%d", &Q);

  i64 sum = 0, mul = -1;
  i64 mn = 0, mx = X;
  int l = 1;
  
  while (Q--) {
    int T;
    i64 A;
    scanf("%d%lld", &T, &A);
    while (l <= K && R[l] <= T) {
      sum += (R[l] - R[l - 1]) * mul;
      mn += (R[l] - R[l - 1]) * mul;
      mx += (R[l] - R[l - 1]) * mul;
      get(mn), get(mx), mul = -mul;
      l++;
    }
    
    A += sum;
    if (A < mn) A = mn;
    if (A > mx) A = mx;
    A += (T - R[l - 1]) * mul;
    
    get(A);
    printf("%lld\n", A);
  }
  
  return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    string p;
    cin >> p;
    cout << "#" << p << "#";
    cout << endl;
  }
  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
}

Measured memory_bytes: 256
import sys
import numpy as np
TYPE_NUM = 26
DAYS = 7

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        opt_delta_satis = -10 ** 32
        opt_idx = 0
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis = np.sum(-c*(d+1-last)) + val
            if opt_delta_satis < temp_delta_satis:
                opt_delta_satis = temp_delta_satis
                opt_idx = idx
            last[idx] = org
        last[opt_idx] = d+1
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()

Measured memory_bytes: 27556
from bisect import bisect_right
N = int(input())
Alist = [int(input()) for i in range(N)]

num_col = 1
L = [-1*Alist[0]] 
for ai in Alist[1:]:
    #print(L)
    ai =-1*ai
    if ai >= L[-1]:
        L.append(ai)
        num_col += 1
    else:
        L[bisect_right(L, ai)] = ai
print(num_col)

Measured memory_bytes: 11804
#include <iostream>
#include <queue>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
const int INF = 1e9+7;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using pipii = pair<int, pii>;


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vvi edge(N, vi(N, INF));
  vvi d(N, vi(N, INF));

  ll A[N][N];
  ll ans = 0;
  rep(i, N) rep(j, N) {
    cin >> A[i][j];
    if (i != j) {
      edge[i][j] = A[i][j];
      d[i][j] = A[i][j];
    }
    if (i < j)
      ans += A[i][j];
  }
  rep(k, N) rep(i, N) rep(j, N)
    d[i][j] = min(d[i][k] + d[k][j], d[i][j]);

  rep(i, N) rep(j, N) {
    if (i >= j)
      continue;
    rep(k, N) {
      if (i == k || k == j)
        continue;
      if (d[i][k] + d[k][j] == A[i][j]) {
        ans -= A[i][j];
        break;
      }
      if (d[i][k] + d[k][j] < A[i][j]) {
        cout << "-1\n";
        return 0;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll a;
    cin >> a;

    COUT(a + a * a + a * a* a);

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,j,N,k = 0,flag = 1,*p;
  scanf("%d",&N);
  if(N < 1 || N >100)exit(1);
  
  p = malloc(N * sizeof(int));

  for(i=0;i < N;i++){
    scanf("%d",&p[i]);
    if(p[i] < 0 || p[i] >100)exit(2);
  }
  while(flag){
    flag = 0;
    for(i = N - 1;i >= 1;i--){
      if(p[i] < p[i-1]){
	j = p[i];
	p[i] = p[i-1];
	p[i-1] = j;
	k++;
	flag = 1;
      }
    }
  }
  for(i=0;i < N;i++){
    if(i != N-1)printf("%d ",p[i]);
    else printf("%d\n",p[i]);
  }
  printf("%d\n",k);
  return 0;
}



Measured memory_bytes: 2104
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
 
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
 
S = sum(A)
memory = [0] * 100001
for num in A:
    memory[num] += 1
for i in range(Q):
  S = S + memory[B[i]] * (C[i]- B[i])
  print(S)
  memory[C[i]] += memory[B[i]]
  memory[B[i]] = 0
  
 

Measured memory_bytes: 22080
#include<stdio.h>
#define long long long
long n, ans, a[20];
long dfs(long x, long s0, long s1) {
    if(x == 1ll) {
        return 2 * s0 + 11 * s1 + 2 * a[x]; 
    }
    return dfs(x - 1ll, s0, s1 * 10ll + a[x]) + dfs(x - 1ll, s0 + s1, a[x]);
}
int main() {
    scanf("%lld", &n);
    while(n) {
        ++ans;
        a[ans] = n % 10;
        n /= 10;
    }
    printf("%lld", dfs(ans, 0ll, 0ll) / 2ll);
    return 0;
}

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

using namespace std;

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

int N;
char S[300005];
int main() {
  scanf("%d", &N);
  scanf("%s", S + 1);
  int cntLeft = 0, cntRight = 0;
  for (int i = 2; i <= N; i++) {
    cntRight += (S[i] == 'E');
  }
  int res = cntRight;
  for (int i = 2; i <= N; i++) {
    cntLeft += (S[i - 1] == 'W');
    cntRight -= (S[i] == 'E');
    res = min(res, cntLeft + cntRight);
  }
  printf("%d\n", res);
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	
	int ans=0,cnt=0;

	for(int i=0; i<s.size(); i++){
		if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='C'||s.at(i)=='G'){
			cnt++;
			if(ans < cnt) ans = cnt;
		}
		else cnt = 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
import sys
import math
input=sys.stdin.readline


n,a=map(int,input().split())
arr=list(map(int,input().split()))
flag=0
for i in range(a):
    n=n-arr[i]
    if(n<=0):
        flag=1
if(flag):
    print("Yes")
else:
    print("No")





Measured memory_bytes: 13984
#include <iostream>
using namespace std;
int main() 
{
	int n,k;
	cin>>n>>k;
	int t=1;
	for(int i=1;i<=n;i++)
	{
		if(t<=k)  t*=2;
		else t+=k;
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256