akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void assert_NO(T condition){ if(!condition){ cout << "NO" << endl; exit(0); } }
template<class T> inline void assert_No(T condition){ if(!condition){ cout << "No" << endl; exit(0); } }
template<class T> inline void assert_minus_1(T condition){ if(!condition){ cout << -1 << endl; exit(0); } }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b){ if(b < a){ a = b; return 1; } return 0; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main(){
    int N, M;
    cin >> N >> M;
    int A[N];
    cins(A, A + N);
    int all = accumulate(A, A + N, 0);
    int ans = 0;
    rep(i, N){
        ans += (A[i] * M * 4 >= all);
    }
    Yes(ans >= M);
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans: usize = 1;

    while ans * ans <= n {
        ans += 1;
    }
    println!("{}", (ans - 1) * (ans - 1));
}


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

int main() {

	int x, y;

	for (int i = 0; ; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;

		if (x > y)
			cout << y << " " << x << "\n";
		else
			cout << x << " " << y << "\n";
	}
}

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

const int N = 1000000;
int dp[2][N+1],nxt,val,i,j,n;

int main(){
  for(i=0;i<=N;i++)dp[0][i] = dp[1][i] = N;
  dp[0][0] = dp[1][0] = 0;

  val = 1;
  for(i=1;val<=N;i++){
    for(j=0;j+val<=N;j++){
      nxt = j+val;
      dp[0][nxt] = min(dp[0][nxt],dp[0][j] + 1);
      if(val&1)dp[1][nxt] = min(dp[1][nxt],dp[1][j] + 1);
    }
    val = i*(i+1)*(i+2)/6;
  }

  while(scanf("%d",&n),n)printf("%d %d\n",dp[0][n],dp[1][n]);
}

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

#define FOR(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)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int ans=0;
  int n; cin >> n;
  llong k; cin >> k;
  vector<int> a(n), b(n); REP(i,n) cin >> a[i] >> b[i];
  vector<llong> vec(100010,0);

  for (int i=0; i<n; i++) {
    vec[a[i]] += b[i];
  }
  llong count=0;
  for (int i=0; i<100010; i++) {
    count += vec[i];
    if (count >= k) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 1792
$p{"3"} = 100000;
$p{"2"} = 200000;
$p{"1"} = 300000;
while(<>){
	chomp;
	($n, $m) = split(/ /, $_);
}
$r = 0;
$r += $p{$n} if(($n >= 1) and ($n <= 3));
$r += $p{$m} if(($m >= 1) and ($m <= 3));
$r += 400000 if(($n == 1) and ($m == 1));
print "$r\n";


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a.at(i);
		a.at(i) -= i + 1;
	}
	sort(all(a));
	int b = a.at(n / 2);
	ll ans = 0;
	rep(i,n) ans += abs(b - a.at(i));
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define NIL -2000000001
int main(){
  int i,n;
  int A[502];
  scanf("%d",&n);
 
  for(i=0;i<502;i++){
    A[i]=NIL;
  }
 for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1)printf("parent key = %d, ",A[i/2]);
    if(A[2*i]!=NIL){
      printf("left key = %d, ",A[2*i]);
      if(A[2*i+1]!=NIL)printf("right key = %d, ",A[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}

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

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[] corr = Arrays.copyOf(a, a.length);
        Arrays.sort(corr);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                swap(a, i, j);
                if (same(a, corr)) {
                    System.out.println("YES");
                    return;
                }
                swap(a, i, j);
            }
        }
        System.out.println("NO");
    }

    boolean same(int[] a, int[] b) {
        for (int i = 0; i < a.length; i++) {
            if (a[i] != b[i]) return false;
        }
        return true;
    }

    void swap(int[] a, int i, int j) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    /*
    cin >> a >> b >> c;
    cout << a << " " << b << " " << c <<endl
    */
    int a[4][3][10];
    int b,f,r,v,x;
    cin >> x;
    for(int bb=0;bb<4;bb++){
        for(int ff=0;ff<3;ff++){
            for(int rr=0;rr<10;rr++){
                a[bb][ff][rr]=0;
            }
        }
    }
    for(int i=0;i<x;i++){
        cin >> b>> f>> r>> v;
        a[b-1][f-1][r-1]+=v;
    }
    for(int bb=0;bb<4;bb++){
        for(int ff=0;ff<3;ff++){
            for(int rr=0;rr<10;rr++){
                cout << " "<< a[bb][ff][rr];
              //  if(rr!=9)cout <<" ";
            }
            cout << '\n';
        }
        if(bb!=3)cout <<"####################"<< endl;
    }
}

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

using namespace std;
#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
	int p, m, c;
	cin >> p >> m >> c;
	cout << p + m + c << endl;
}


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

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

  vector<int> x;
  vector<int> y;
  vector<long long> h;
  int sx, sy, sh=-1;
  for(int i=0;i<N;i++){
    int temp1, temp2;
    long long temp3;
    cin >> temp1 >> temp2 >> temp3;
    x.push_back(temp1);
    y.push_back(temp2);
    h.push_back(temp3);

    if(sh<0 && temp3>0){
      sx = temp1;
      sy = temp2;
      sh = temp3;
    }
  }

  for(int cy=0;cy<=100;cy++){
    for(int cx=0;cx<=100;cx++){
      long long sH = sh+abs(sx-cx)+abs(sy-cy);
      //sH = max(sH, 0LL);
      bool flag = true;

      for(int n=0;n<N;n++){
        long long H = sH-abs(x[n]-cx)-abs(y[n]-cy);
        H = max(H, 0LL);
        if(H != h[n]){
          flag = false;
          break;
        }
      }

      if(flag){
        cout << cx << " " << cy << " " << sH << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    //try {
      Scanner input = new Scanner(System.in);
      int height = Integer.valueOf(input.next());
      int width = Integer.valueOf(input.next());
      
      //if (1 <= height && width <= 100) {
        int squareArea = calcSquareArea(height, width);
        int squarePerimeter = calcSquarePerimeter(height, width);
        System.out.println(squareArea + " " + squarePerimeter);
      //}
    //} catch (IOException e) {
      //System.exit(0);
    //}
  }

  private static int calcSquarePerimeter(int height, int width) {
    return (height * 2) + (width * 2);
  }

  /**
   * 四角形の面積を計算する
   * @param height
   * @param width
   * @return
   */
  private static int calcSquareArea(int height, int width) {
    return height * width;
  }
}


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

int main(void){
  
long long a,b,k;
  
  cin>>a>>b>>k;
  
if(a>=k) cout<<a-k<<" "<<b<<endl;

else if(a+b>k) cout<<0<<" "<<b+a-k<<endl;
  
else cout<<0<<" "<<0<<endl;
  
}
  

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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double n;
    cin >> n;
    double odd = (int)n/2;
    if ((int)n%2==1) odd++;
    cout << fixed << setprecision(9) << odd/n << '\n';
}
/*

 */

Measured memory_bytes: 3696
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;;
using ll = long long;

int main() {
	ll x;
	cin >> x;
	ll hap = 0;

	hap += (x / 500)*1000;
	hap += ((x % 500) / 5) * 5;
	cout << hap;

	return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int H, W, D, A[300][300];
  int X[1000000], Y[1000000];
  cin >> H >> W >> D;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> A[i][j];
      X[A[i][j]] = j;
      Y[A[i][j]] = i;
    }
  }

  vector< int > add[1000000];
  for(int i = 1; i <= H * W; i++) {
    add[i % D].emplace_back(i);
  }
  vector< int64 > sum[1000000];
  for(int i = 0; i < D; i++) {
    sum[i].resize(add[i].size());
    for(int j = 1; j < add[i].size(); j++) {
      sum[i][j] += sum[i][j - 1];
      sum[i][j] += abs(X[add[i][j - 1]] - X[add[i][j]]);
      sum[i][j] += abs(Y[add[i][j - 1]] - Y[add[i][j]]);
    }
  }


  int Q;
  cin >> Q;
  while(Q--) {
    int L, R;
    cin >> L >> R;
    int p = L % D;
    int latte = lower_bound(begin(add[p]), end(add[p]), L) - begin(add[p]);
    int malta = lower_bound(begin(add[p]), end(add[p]), R) - begin(add[p]);
    cout << sum[p][malta] - sum[p][latte] << endl;
  }
}

Measured memory_bytes: 56064
const teststr = 
"""
5 7 4
"""

function lines()
  Channel{String}(32) do ch
    ll = readlines()
    lines = isempty(ll) ? split(teststr, "\n") : ll
    for s in lines
      put!(ch, s)
    end
  end
end

quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

function main()
  ch = lines()
  A,B,N = in_a(ch)
  if N < B
    x = N
    floor(A*x/B)-A*floor(x/B) |> Int |> println
  else
    x = B-1
    floor(A*x/B)-A*floor(x/B) |> Int |> println
  end
end

main()


Measured memory_bytes: 189564
#include <bits/stdc++.h>
using namespace std;
int n, q, m;
vector<int> A(20, 0);

bool f(int m, int sum, int cnt)
{
  if (cnt == n)
    return sum == m;
  bool ret1 = f(m, sum + A.at(cnt), cnt + 1);
  bool ret2 = f(m, sum, cnt + 1);
  return ret1 || ret2;
}

int main()
{
  scanf("%d", &n);
  for (int i; i < n; i++)
  {
    scanf("%d", &A.at(i));
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++)
  {
    scanf("%d", &m);
    if (f(m, 0, 0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <limits.h>
using namespace std;
typedef long long ll;


int main()
{
	int N, K;
	cin >> N >> K;
	bool visited[101] = { 0, };
	while (K--)
	{
		int cnt;
		cin >> cnt;
		while (cnt--)
		{
			int tmp;
			cin >> tmp;
			visited[tmp] = true;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++)
		if (!visited[i])ans++;
	cout << ans;
}

Measured memory_bytes: 3624
s=int(input())

if s==4 or s==2 or s==1:
    print(4)
    

else:
    l=[]
    for i in range(10**6+1):
        l.append(s)
        if l.count(4)>2:
            break
        elif s%2==0:
            s=s//2
        else:
            s=3*s+1
    x=l.index(4)

    l=l[x+1:]
    y=l.index(4)

    print(y+x+2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<string>a;

    int i,j,n,p,q,r,k,y,l;
    string b;
    cin>>n;
    for(i=0;i<n;i++)
    { cin>>b;
     a.insert(b);
    }
    cout<<a.size()<<endl;
return 0;
}





Measured memory_bytes: 19188
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
//dp

bool x[16001][4000];
bool y[16001][4000];

// s_num is previous index
void forward(int flen, string dir, int s_num){
	if(flen != 0){
		if(dir.compare("rol") == 0){
			for(int i=0; i<16001; i++){
				if(x[i][s_num]){
					x[i+flen][s_num+1] = true;
					x[i-flen][s_num+1] = true;
				}
				if(y[i][s_num]){
					y[i][s_num+1] = true;
				}
			}
		} else if(dir.compare("uod") == 0){
			for(int i=0; i<16001; i++){
				if(x[i][s_num]){
					x[i][s_num+1] = true;
				}
				if(y[i][s_num]){
					y[i+flen][s_num+1] = true;
					y[i-flen][s_num+1] = true;
				}
			}
		} else if(dir.compare("r") == 0){
			for(int i=0; i<16001; i++){
				if(x[i][s_num]){
					x[i+flen][s_num+1] = true;
				}
				if(y[i][s_num]){
					y[i][s_num+1] = true;
				}
			}
		}
	}
}

int main(int argc, char const *argv[])
{

	char S[8000];
	string STR;
	int zero = 8000;
	x[zero][0]=true;
	y[zero][0]=true;
	int X,Y;
	scanf("%s", S);
	STR = S;
	scanf("%d%d",&X,&Y);

	int flen = 0;
	string dir = "r";
	int s_num = 0;
	for(int i=0; i<(int)STR.length(); i++){
		switch(STR[i]){
			case 'F':
				flen++;
				break;
			case 'T':

				// cout << "T: flen,s_num=" << flen << "," << s_num << endl;
				forward(flen, dir, s_num);
				if(flen != 0){
					s_num++;
				}
				flen=0;

				if(dir.compare("rol") == 0){
					dir = "uod";
				} else if(dir.compare("uod") == 0){
					dir = "rol";
				} else if(dir.compare("r") == 0){
					dir = "uod";
				}
				break;
		}
	}

	// cout << "T: flen,s_num=" << flen << "," << s_num << endl;
	forward(flen, dir, s_num);
	if(flen != 0){
		s_num++;
	}
	flen=0;

	// debug
	// for(int i=0;i<16001;i++){
	// 	for(int j=0;j<16001;j++){
	// 		for(int s=0;s<s_num+1;s++){
	// 			if(x[i][s] && y[j][s]){
	// 				cout << "(" << i << "," << j << ")" << endl;
	// 			}
	// 		}
	// 	}
	// }
	// for(int i=0;i<16001;i++){
	// 	for(int j=0;j<16001;j++){
	// 			if(x[i][s_num] && y[j][s_num]){
	// 				cout << "(" << i << "," << j << ")" << endl;
	// 			}
	// 	}
	// }

	if(x[zero+X][s_num] && y[zero+Y][s_num]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 65792
#include<stdio.h>

int main(void) {
	int a, b, c;
	int max;
	char buf[128];
	
	fgets(buf,128,stdin);
	sscanf(buf,"%d %d %d",&a,&b,&c);
	
	max = a;
	if(b > a && b > c) {
		max = b;
	}
	if(c > a && c > b) {
		max = c;
	}
	
	printf("%d\n",a+b+c-max);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  bool flag = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') {
      flag = 1;
    }
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  if (flag) {
    x = -x;
  }
}
const int N = 300005;
int w, h, n, x[N], y[N], ans;
int px[N], nx, py[N], ny;
struct SegmentTree {
  int l[N << 2], r[N << 2];
  int val[N << 2], lazy[N << 2];
  inline void pushup(int p) {
    val[p] = max(val[p << 1], val[p << 1 | 1]);
  }
  void build(int p, int L, int R) {
    l[p] = L, r[p] = R;
    val[p] = -py[L - 1] + w;
    lazy[p] = 0;
    if (L == R) {
      return;
    }
    int mid = l[p] + r[p] >> 1;
    build(p << 1, L, mid);
    build(p << 1 | 1, mid + 1, R);
  }
  inline void tag(int p, int v) {
    val[p] += v;
    lazy[p] += v;
  }
  inline void pushdown(int p) {
    if (lazy[p]) {
      tag(p << 1, lazy[p]);
      tag(p << 1 | 1, lazy[p]);
      lazy[p] = 0;
    }
  }  
  void modify(int p, int L, int R, int v) {
    if (l[p] >= L && r[p] <= R) {
      tag(p, v);
      return;
    }
    pushdown(p);
    int mid = l[p] + r[p] >> 1;
    if (mid >= L) {
      modify(p << 1, L, R, v);
    }
    if (mid < R) {
      modify(p << 1 | 1, L, R, v);
    }
    pushup(p);
  }
} smt;
inline void process() {
  static int lef[N], rig[N];
  smt.build(1, 1, ny);
  for (int i = 1; i <= ny; ++i) {
    lef[i] = 0;
    rig[i] = w;
  }
  for (int i = 1; i <= n; ++i) {
    int X = px[x[i]], Y = y[i];
    if (X <= w / 2) {
      lef[Y] = max(lef[Y], X);
    } else {
      rig[Y] = min(rig[Y], X);
    }
  }
  static int sl[N], sr[N];
  int tl = 0, tr = 0;
  for (int i = 1; i <= ny; ++i) {
    ans = max(ans, 2 * (py[i] + smt.val[1]));
    smt.modify(1, i, i, -lef[i] + rig[i] - w);
    while (tl && lef[sl[tl]] < lef[i]) {
      smt.modify(1, sl[tl - 1] + 1, sl[tl], lef[sl[tl]] - lef[i]);
      --tl;
    }
    sl[++tl] = i;
    while (tr && rig[sr[tr]] > rig[i]) {
      smt.modify(1, sr[tr - 1] + 1, sr[tr], rig[i] - rig[sr[tr]]);
      --tr;
    }
    sr[++tr] = i;
  }
}
int main() {
  scanf("%d%d%d", &w, &h, &n);
  px[++nx] = w;
  py[++ny] = h;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    px[++nx] = x[i];
    py[++ny] = y[i];
  }
  sort(px + 1, px + nx + 1);
  sort(py + 1, py + ny + 1);
  nx = unique(px + 1, px + nx + 1) - px - 1;
  ny = unique(py + 1, py + ny + 1) - py - 1;
  for (int i = 1; i <= n; ++i) {
    x[i] = lower_bound(px + 1, px + nx + 1, x[i]) - px;
    y[i] = lower_bound(py + 1, py + ny + 1, y[i]) - py;
  }
  process();
  swap(w, h);
  swap(px, py);
  swap(nx, ny);
  swap(x, y);
  process();
  printf("%d\n", ans);
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> D(n);
    rep(i, n) cin >> D.at(i);

    int ans = 0, max;
    rep(i, n) {
        max = 0;
        rep(i, n) {
            if(D.at(i) > max) max = D.at(i);
        }
        rep(i, n) {
            if(D.at(i) == max) D.at(i) = 0;
        }
        if(max != 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

#define ll long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define viit vector<int>::iterator
#define MOD 1000000007
#define endl "\n"
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define repd(i, a, b) for (int i = (a); i >= (b); i--)
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll h[n][3], t[n][3];
    rep(i, 0, n) cin >> h[i][0] >> h[i][1] >> h[i][2];
    rep(i, 1, n) {
        rep(j, 0, 3) {
            ll m = -1;
            rep(k, 0, 3) {
                if (j == k) continue;
                m = max(m, h[i-1][k]);
            }
            h[i][j] += m;
        }
    }
    cout << max({h[n - 1][0], h[n-1][1], h[n-1][2]});
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int money;
	scanf("%d", &n);
	
	money = 100000;
	
	for (i = 0; i < n; i++){
		money = money + (money / 20);
		money = (money + 999) / 1000 * 1000;
	}
	
	printf("%d\n", money);
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d",&a,&b);
	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1792
from collections import deque

N,M=map(int,input().split())
AB=[map(int,input().split()) for _ in range(M)]

links=[[] for _ in range(N+1)]
for a,b in AB:
  links[a].append(b)
  links[b].append(a)
  
result=[-1]*(N+1)
q=deque([1])
while q:
  i=q.popleft()
  for j in links[i]:
    if result[j]==-1:
      result[j]=i
      q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll P = 1000000007;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;
  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }
  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }
  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }
  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }
  long long mul(long long a, long long b) { return (a * b) % P; }
  long long add(long long a, long long b) { return (a + b) % P; }
  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

ll dp[101010][202] = {0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  vector<ll> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  ll cnt = 0;
  for (int i = 0; i < n; i++)
    if (v[i] <= x)
      cnt++;
  dp[x][n] = 1;
  for (int i = x; i > 0; i--) {
    for (int j = n; j > 0; j--) {
      if (dp[i][j] == 0)
        continue;
      dp[i][j - 1] += (dp[i][j] * (j - 1)) % P;
      dp[i][j - 1] %= P;
      dp[i % v[j - 1]][j - 1] += dp[i][j];
      dp[i % v[j - 1]][j - 1] %= P;
    }
  }
  ll ans = 0;
  for (ll i = 0; i <= x; i++) {
    ans += (i * dp[i][0]) % P;
    ans %= P;
  }
  cout << ans << endl;

  return 0;
  ll ans2 = 0;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
    p[i] = i;
  do {
    ll y = x;
    for (int i = 0; i < n; i++) {
      y %= v[p[i]];
    }
    ans2 += y;
    ans2 %= P;
  } while (next_permutation(p.begin(), p.end()));
  cerr << ans2 << endl;

  return 0;
}


Measured memory_bytes: 69888
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    ll N, A[5];
    cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];

    ll ans = 0;
    ll hikaku = A[0];
    // cout << "===" << endl;
    for (int i = 0; i < 5; ++i) {
        if (i == 0) {
            ans = N % A[0] == 0 ? (N / A[i]) : (N / A[i]) + 1;
            continue;
        }
        ll div = A[i];
        if (div > hikaku) {
            div = hikaku;
        } else {
            hikaku = div;
        }
        ll tmp = N % div == 0 ? (N / div) : (N / div) + 1;
        tmp += i;
        // cout << tmp << endl;
        if (ans < tmp) {
            ans = tmp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

const int N = 100;

int min(int a, int b);

int main(){
  int i, j, k, l;
  int n, p[N+1], m[N+1][N+1];
  scanf("%d", &n);
  
  for(i=0; i<N; i++){
      i++;
      i--;
  }
  
  for ( i = 1; i <= n; i++ ){
    scanf("%d %d", &p[i-1], &p[i]);
  }

  for ( i = 1; i <= n; i++ ) m[i][i] = 0;
  for ( l = 2; l <= n; l++ ){
    for ( i = 0; i <= n-l+1; i++ ){
      j = i+l-1;
      m[i][j] = (1<<21);
      for ( k = i; k <= j-1; k++ ){
	m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }

  printf("%d\n", m[1][n]);
  
  return 0;
}

int min(int a, int b){ 
    int min;
    if(a < b) {
        min = a;
    } else {
        min = b;
    }
    return min;
}


Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <ctype.h>

using namespace std;
using ll=long long;

int main()
{
    string s1, s2, s3;
    
    cin >> s1 >> s2 >> s3;
    
    printf("%c%c%c\n",
        toupper(s1.front()), toupper(s2.front()), toupper(s3.front()));
    
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

const int M = 100100;

int n, m;
int a[M];

void read() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        a[x] ^= 1;
        a[y] ^= 1;
    }
}

void kill() {
    int mx = *max_element(a, a + n);
    if (mx == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



Measured memory_bytes: 640
n = int(input())
a = [int(i) for i in input().split()]

A = 0
B = 0
while len(a) > 0:
  A += max(a)
  a.remove(max(a))
  if len(a) > 0:
    B += max(a)
    a.remove(max(a))
  
print(A-B)

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
int main(void)
{
	char s[11];
	scanf("%s", s);

	if (s[0] != 'A') {
		puts("WA");
		return 0;
	}

	int len = strlen(s);
	int cnt = 0;
	int index;

	for (int i = 2; i < len - 1; i++) {
		if (s[i] == 'C') {
			cnt++;
			index = i;
		}
	}

	if (cnt != 1) {
		puts("WA");
		return 0;
	}

	for (int i = 1; s[i] != '\0'; i++) {
		if (i == index)
			continue;
		if (s[i] < 'a' || s[i] > 'z') {
			puts("WA");
			return 0;
		}
	}
	printf("AC\n");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[200010];
int f[200010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read(),k=read();
    scanf("%s",ss+1);
    int mx=0;
    for(int i=n;i>=1;i--)
    {
    	f[i]=f[i+1];
    	if(i+k+1<=n)mx=max(mx,f[i+k+1]);
    	if(ss[i]=='o')f[i]=mx+1;
    }
	int st=0,cnt=0;
    for(int i=1;i<=n;i++)
    {
    	if(ss[i]=='o')
    	{
    		if(st==0 || st+k+1<=i)
    		{
    			cnt++;st=i;
    			if(cnt+f[i+1]-1<m)pr2(i);
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 2432
import Foundation

let divider = 1000000007

extension Int {
    func pow(_ x: Int) -> Int {
        if x == 0 {
            return 1
        } else {
            return self * self.pow(x - 1) % divider
        }
    }
}

let n = Int(readLine()!)!
let result = (10.pow(n) - 9.pow(n) - 9.pow(n) + 8.pow(n)) % divider
print(result < 0 ? result + divider : result)


Measured memory_bytes: 44032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    const int N_MAX = 100010;
    ll front_sum[N_MAX] = {};
    ll end_sum[N_MAX] = {};
    VI midv;
    priority_queue<int, VI, greater<int>> frontpq;
    priority_queue<int> endpq;
    cin >> n;
    REP(i, 3 * n){
        int a;
        cin >> a;
        if(i < n){
            frontpq.push(a);
            front_sum[0] += a;
        }else if(i < n * 2){
            midv.push_back(a);
        }else{
            endpq.push(a);
            end_sum[n] += a;
        }
    }

    REP(i, n){
        frontpq.push(midv[i]);
        front_sum[i + 1] = front_sum[i] + midv[i] - frontpq.top();
        frontpq.pop();
    }
    FORR(i, n - 1, 0){
        endpq.push(midv[i]);
        end_sum[i] = end_sum[i + 1] + midv[i] - endpq.top();
        endpq.pop();
    }

    ll ans = front_sum[0] - end_sum[0];
    FOR(i, 1, n){
        ans = max(ans, front_sum[i] - end_sum[i]);
    }
    cout << ans << "\n";

    return 0;
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
int sum=0;
rep(i,n){
    sum+=(i+1);
}
cout<<sum<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace ConsoleApp1
{
    using static Util;

    internal class Program
    {

        static void Main(string[] args)
        {
            var k = ReadIntArray()[1];
            var s = Console.ReadLine();
            var res = string.Join("", s.Select((x, idx) => idx == k - 1 ? x.ToString().ToLower() : x.ToString()).ToArray());
            Console.WriteLine($"{res}");
#if DEBUG
            Console.Read();
#endif
        }
    }

    public static class Util
    {
        public static long[] ReadLongArray() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        public static int[] ReadIntArray() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        public static long ReadLong() => long.Parse(Console.ReadLine());
        public static long ReadInt() => int.Parse(Console.ReadLine());
    }
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll A, B, K;
    cin >> A >> B >> K;
    for(ll i = A;i <= B;i++) {
        if(i - A < K || B - i < K) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int a[5];
int main()
{
    go;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1]&&a[0]!=a[2])
        cout<<"Yes";
    else if(a[1]==a[2]&&a[1]!=a[0])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,T;
	cin>>n>>T;
	vector<ll> t(n+1,inf);
	rep(i,n){
		cin>>t[i];
	}
	ll ans=0;
	rep(i,n){
		ans+=min(T,t[i+1]-t[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public void calculate(){
		Scanner input = new Scanner(System.in);

		//?????????????????¶??°???????????????
		long numSellings = Long.parseLong(input.nextLine());

		//?????????????????¶??°???0??????????????§????????????
		while(numSellings != 0){

			//??????????????????????????????????????¬?????????????????????????????????
			ArrayList<Long> staffs = new ArrayList<Long>();
			//????????¨????£??????????????????????
			HashMap<Long,Long> staffProceedMap = new HashMap<Long,Long>();

			//??¶??°?????§?¨?????????????
			for(int i = 0; i < numSellings; i++){
				//??????????????????????????????????????¨??????????£?????£??????????????¨??????????
				String[] lines = input.nextLine().split(" ");
				long staffNo = Long.parseLong(lines[0]);
				long price   = Long.parseLong(lines[1]) * Long.parseLong(lines[2]);

				//????????????????????????????£??????±?????\?????????
				if(staffProceedMap.containsKey(staffNo)){
					//2?????\??????????£?????????£????????????value????¶???????????????¢?????????
					staffProceedMap.put(staffNo,price + staffProceedMap.get(staffNo));
				} else {
					//1????????????????£?????????£?????????????????????????????????????????±???????????????
					staffs.add(staffNo);
					staffProceedMap.put(staffNo,price);
				}
			}

			//??¨???????????????????????§???????????¨??????????????¨??????
			boolean success = false;

			//???????????????????????§????????????????£?????????????????????????
			for(long staff : staffs){
				if(staffProceedMap.get(staff) >= 1000000){
					System.out.println(staff);
					success = true;
				}
			}

			if(!success){
				System.out.println("NA");
			}
			numSellings = Long.parseLong(input.nextLine());
		}
		input.close();
	}

	public static void main (String[] args) throws java.lang.Exception{

		Main saleResult = new Main();
		saleResult.calculate();
	}
}

Measured memory_bytes: 31640
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
struct matrix {
	LL a[10][10];
	int n , m;
	matrix operator + (const matrix &b) const {
		matrix c;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= b.m; ++j) {
				c.a[i][j] = 0;
			}
		}
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= b.m; ++j) {
				c.a[i][j] = (a[i][j] + b.a[i][j]) % mod;
			}
		}
		c.n = n;
		c.m = b.m;
		return c;
	}
	matrix operator * (const matrix &b) const{
		matrix c;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= b.m; ++j) {
				c.a[i][j] = 0;
			}
		}
		for (int i = 1; i <= n; ++i) {
			for (int k = 1; k <= m; ++k) {
				for (int j = 1; j <= b.m; ++j) {
					c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j] % mod) % mod;
				}
			}
		}
		c.n = n;
		c.m = b.m;
		return c;
	}
	void write() {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				printf("%lld " , a[i][j]);
			}
			putchar('\n');
		}
	}
}I; 
matrix qpow(matrix a , int b) {
	matrix res = I;
	while(b) {
		if(b & 1) res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
int main() {
	matrix A , B;
	I.a[1][1] = I.a[2][2] = I.a[3][3] = 1;
	I.n = I.m = A.n = A.m = B.n = B.m = 3;
	A.a[1][1] = 1 , A.a[1][2] = 0 , A.a[1][3] = 1;
	A.a[2][1] = 1 , A.a[2][2] = 1 , A.a[2][3] = 1;
	A.a[3][1] = 1 , A.a[3][2] = 2 , A.a[3][3] = 2;
	B.a[1][1] = 1 , B.a[1][2] = 0 , B.a[1][3] = 0;
	B.a[2][1] = 1 , B.a[2][2] = 1 , B.a[2][3] = 0;
	B.a[3][1] = 1 , B.a[3][2] = 2 , B.a[3][3] = 1;
	matrix res = I;
	int n , m;
	scanf("%d %d" , &n , &m);
	int las = 0;
	for (int i = 1; i <= m; ++i) {
		int x;
		scanf("%d" , &x);
		matrix tmp = qpow(A , x - las - 1);
		res = res * tmp * B;
		las = x;
	}
	res = res * qpow(A , n - las - 1);
	printf("%lld" , (res.a[3][1] + res.a[3][2] + res.a[3][3]) % mod);
	return 0;
}

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

int n,l;
int mn,sum;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>l;
    mn=1e9;
    for(int i=1;i<=n;i++){
        int c=l+i-1;
        if(abs(c)<abs(mn))mn=c;
        sum+=c;
    }
    cout<<sum-mn<<endl;

    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
a = (1,3,5,7,8,10,12)
b = (4, 6, 9, 11)
c = (2, )
 
for g in (a, b, c):
  if x in g and y in g:
    print('Yes')
    break
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;

int main() {
	string S;
	cin >> S;

	if (S.length() == 1) {
		cout << 0 << endl;
		return 0;
	}


	char before = S[0];
	ull count = 0;
	for (size_t i = 1; i < S.length(); i++) {
		char now = S[i];

		if (before == now) {
			count++;
			if (now == '0') {
				now = '1';
			} else {
				now = '0';
			}
		}
		before = now;
	}

	cout << count << endl;


	return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  char s[12];
  int i,ans=1000,n;
  scanf("%s",s);
  for(i=0;s[i+2]!='\0';i++){
    n=100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
    if(n>753) ans=(n-753<ans?n-753:ans);
    else ans=(753-n<ans?753-n:ans);
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	// Code for A - Kth Term
	A := [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var K int
	fmt.Scanf("%d", &K)

	fmt.Println(A[K-1])
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
	int n, dis, atk;
	ll ans, dmg;
	vec<pii> v;
	queue<pll> q;
	
	dmg = ans = 0;
	
	cin >> n >> dis >> atk;
	v.rs(n);
	rep(i, n) cin >> v[i].F >> v[i].S;
	sort(ALL(v));
	for(auto i:v){
		while(!q.empty() && q.front().F < i.F){
			dmg -= q.front().S;
			q.pop();	
		}
		i.S -= dmg;
		if(i.S > 0){
			ll tmp = ceil(double(i.S) / atk);
			ans += tmp;
			tmp *= atk;
			q.push(MP(i.F + dis * 2, tmp));
			dmg += tmp;
		}
	}
	cout << ans << '\n';
}

int main(){
	int t = 1;
	
	while(t--){
		solve();
	}
}




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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ld A, B, H, M;
    cin >> A >> B >> H >> M;
    ld tm = 6 * M;
    ld th = 30 * H + 0.5 * M;
    ld t = abs(tm - th);
    t = min(t, 360 - t);
    t = deg_to_rad(t);
    cout << fixed << setprecision(15)
         << sqrt(A * A + B * B - 2 * A * B * cos(t)) << endl;

    return 0;
}


Measured memory_bytes: 4084
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

H.reverse()
p = [0]
x = 0
for i in range(N-1):
    if H[i] <= H[i+1]:
        x += 1
        p.append(x)
    else:
        x = 0

print(max(p))


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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;cin>>s;
    int n=s.size();
    int k=1;
    int last=1;
    for(int i=1;i<n;){
        if (last==2){
            last=1;
            ++i;
        }else if (s[i]!=s[i-1]) {
            ++i;
        }else if (i+1==n) break;
        else{
            last=2;
            i += 2;
        }
        ++k;
    }
    cout << k;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  bool ans=true;
  int s=0;
  for(int i=0;i<n;i++){
    if(s-a[i]>=2) ans=false;
    s=max(s,a[i]);
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 640
import math
# -*- coding: utf-8 -*-
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = math.sqrt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1
 
print(num)

Measured memory_bytes: 9196