akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=int(1e5)+5;

char s[MAXN];

int main()
{
	int tb=0;
	scanf("%s",s);
	int len=strlen(s);
	int ans=0;
	for(int i=0;i<len;i++) {
		if(s[i]=='p')
			ans--;
		if(tb) ans++,tb--;
		else tb++;
	}
	printf("%d",ans);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

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

    ll res = floor(sqrt(N)) * floor(sqrt(N));

    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace Line
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var min = 30; // 今回はceil(log2(最大値))なら何でもいいです

            var N = cin.ReadInt;
            for (int i = 0; i < N; ++i)
            {
                var A = cin.ReadInt;
                var c = 0;
                while (A % 2 == 0 && A != 0) { A >>= 1; ++c; }
                min = Min(min, c);
            }
            WriteLine(min);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;


int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    ll l = a[0], r = b[0];
    for (int i = 1; i < n; i++) {
        ll x = a[i], y = b[i];
        ll a1 = l / x + (l % x == 0 ? 0 : 1);
        ll a2 = r / y + (r % y == 0 ? 0 : 1);
        ll k = max(a1, a2);
        l = x * k;
        r = y * k;
    }
    cout << l + r;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
ans = int(math.log10(n)+1)
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans, max(int(math.log10(i)+1),int(math.log10(n//i)+1)))
print(ans)
"""

#D
n,a,b = LI()
v = LI()
v.sort()
v = v[::-1]
ans = v[:a]
d = {}
d[ans[-1]] = 0
if ans[0] != ans[-1]:
    for i in ans:
        if i == ans[-1]:
            d[i] += 1
    k = d[i]
    d[i] = 0
    for i in v:
        if i == ans[-1]:
            d[i] += 1
    c = 1
    for j in range(min(k,d[ans[-1]]-k)):
        c *= d[ans[-1]]-j
        c //= j+1
else:
    for i in v:
        if i == ans[-1]:
            d[i] += 1
    c = 0
    for k in range(a,min(d[ans[-1]],b)+1):
        p = 1
        for j in range(min(k,d[ans[-1]]-k)):
            p *= d[ans[-1]]-j
            p //= j+1
        c += p
print(sum(ans)/a)
print(c)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 40560
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    cur = 0
    ans = 0
    for i in range(N):
        cur += A[i]
        ans += 1
        if i == N-1:
            break
        if A[i+1] <= cur*2:
            continue
        else:
            ans = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64368
// #include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ed "\n";
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[n/2]-d[n/2-1]<<ed;
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const int mod = 1000000007;

ll dp[101][100001] = {0};

int main()
{
    int n, W;
    cin >> n >> W;
    vector<int> w(n + 1), v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= W; j++) {
            if (w[i] > j) {
                dp[i][j] = dp[i - 1][j];
            }
            else {
                dp[i][j] = max(dp[i - 1][j],
                               dp[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 81776
#include <bits/stdc++.h>
using namespace std;
int abs(int a){
  if(a<0) a = (-1)*a;
  return a;
}
int pow(int a,int b){
  int ans=1;
  for(int i=0; i<b; i++) ans *=a;
  return ans;
}
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  int odd=0;//奇数の個数
  int absmin=pow(10,9);//絶対値が最小のもの
  int mini=0;
  for(int i=0; i<n; i++){
    int tmp;
    cin>>tmp;
    a.at(i)=abs(tmp);
    if(tmp<0) odd++;
    if(abs(tmp)<absmin){
      absmin=abs(tmp);
      mini=i;
    }
  }
  long long ans=0;
  for(int i=0; i<n; i++){
    if(i!=mini) ans += a.at(i);
    else if( odd%2==1) ans -= a.at(i);
    else ans += a.at(i);
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
  int X, Y, ans=0;
  cin >> X >> Y;
  if(X == 1) ans += 300000;
  if(X == 2) ans += 200000;
  if(X == 3) ans += 100000;
  if(Y == 1) ans += 300000;
  if(Y == 2) ans += 200000;
  if(Y == 3) ans += 100000;
  if(ans == 600000) ans += 400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	num := f(as[0])

	if n == 1 {
		fmt.Println(num)
	} else {
		for i := 1; i < n; i++ {
			tmp := f(as[i])
			if tmp < num {
				num = tmp
			}
		}
		fmt.Println(num)
	}
}

func f(n int) int {
	var num int
	tmp := n
	for tmp%2 == 0 {
		tmp /= 2
		num++
	}
	return num
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        try {
            String line = br.readLine();
            st = new StringTokenizer(line);
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            int l = Integer.parseInt(st.nextToken());
            long[][] matrixA = new long[n][m];
            long[][] matrixB = new long[m][l];
            long[][] matrixC = new long[n][l];
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                for (int j = 0; j < m; j++) {
                    matrixA[i][j] = Integer.parseInt(st.nextToken());
                }
            }
            for (int i = 0; i < m; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                for (int j = 0; j < l; j++) {
                    matrixB[i][j] = Integer.parseInt(st.nextToken());
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < l; j++) {
                    for (int k = 0; k < m; k++) {
                        matrixC[i][j] += matrixA[i][k]*matrixB[k][j];
                    }
                }
            }
            printMatrix(matrixC);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    private static void printMatrix(long[][] matrix){
        for (long[] longs : matrix) {
            StringBuilder sb = new StringBuilder();
            for (long anLong : longs) {
                sb.append(anLong).append(" ");
            }
            System.out.println(sb.toString().trim());
        }
    }
}

Measured memory_bytes: 32152
object Main {
	def main(args:Array[String]) {
		val in = readLine.split(" ").map(_.toInt)
		val a = in(0)
		val b = in(1)
		val c = in(2)
		
		if( a < b && b < c) {
			println("Yes")
		} else {
			println("No")
		}
	}
}

Measured memory_bytes: 43824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
const ll INF = 1<<29;

ll dp[1010][10010];

int main(){
    int h,n; cin >> h >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,1010) rep(j,10010) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n){
        rep(j,10001){
            //dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            if(j>a[i]){
                //dp[i+1][j] = min(dp[i+1][j],dp[i][j-a[i]]+b[i]);
                dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
            }
            else{
                dp[i+1][j] = min(dp[i][j],b[i]);
            }
        }
    }
    cout << dp[n][h] <<endl;
}

Measured memory_bytes: 79232
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int N, W;
    cin>>N>>W;
    vector<int> value(N);
    vector<int> weight(N);
    REP(i, N) {
        cin>>value[i]>>weight[i];
    }
    vector<vector<ll>> dp(N+1, vector<ll>(W+1));
    
    for(long long i=1; i<=N; i++){
        for(long long j=0; j<W+1; j++){
            if(j-weight[i-1]>=0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i-1]] + value[i-1]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


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

using namespace std;

const int N = 1024;

int a[N];
int pos[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", a+i);
  vector<int> ans;
  for (int i = n-1; i >= 0; --i) {
    int now = 0;
    for (int j = 0; j < n; ++j) {
      pos[j] = -2;
      if (a[j] == -1) continue;
      ++now;
      pos[j] = now;
    }
    if (now == 0) break;
    for (int j = n-1; j >= 0; --j) {
      if (pos[j] == a[j]) {
        ans.push_back(a[j]);
        a[j] = -1;
        break;
      }
    }
  }
  if (ans.size() == n) {
    reverse(ans.begin(), ans.end());
    for (int x : ans)
      printf("%d\n", x);
  }
  else
    puts("-1");
  return 0;
}

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

ll d[200001];
int main() {
	int n; scanf("%d", &n);
	map<ll, vector<int>>mp;
	mp[0].push_back(0);
	rep(i, n) {
		scanf("%lld", &d[i + 1]);
		d[i + 1] += d[i];
		mp[d[i + 1]].push_back(i + 1);
	}
	int Max = 0;
	for (auto&p : mp) {
		Max = max(Max, *p.second.rbegin() - *p.second.begin());
	}
	printf("%d\n", Max);
}

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

int main(){
  int N,M; cin >> N >> M;
  set<pair<int,int>> war;
  for(int i=0; i<M; i++){
    int a,b; cin >> a >> b;
    war.insert(make_pair(a,b));
  }
  int result=0;
  while(!war.empty()){
    result++;
    auto itr=war.end(); itr--;
    int a=(*itr).first, b=(*itr).second;
    for(auto c: war){
      if(c.second>a) war.erase(c);
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
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 ALL(v) v.begin(), v.end()

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)

int calc(int a, int b, char ope) {
    if (ope == '+') return a + b;
    if (ope == '-') return a - b;
    if (ope == '*') return a * b;
    return -1;
}

bool isten(string s) {
    int ans;
    if (s[1] == '(') {
        int a, b, c, d;
        a = s[2] - '0';
        b = s[6] - '0';
        c = s[11] - '0';
        d = s[16] - '0';
        ans = calc(calc(calc(a,b,s[4]), c, s[9]), d, s[14]);
    }else {
        int a, b, c, d;
        a = s[1] - '0';
        b = s[5] - '0';
        c = s[11] - '0';
        d = s[15] - '0';
        ans = calc(calc(a, b, s[3]), calc(c, d, s[13]), s[8]);
    }
    return ans == 10;
}

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)


vector<char> operands = {'+', '-', '*'};
random_device rd;

char getRandomOperand() {
    return operands[rd() % 3];
}

void solve41(int a, int b, int c, int d) {
    vector<int> nums;
    nums.push_back(a), nums.push_back(b), nums.push_back(c), nums.push_back(d);
    sort(ALL(nums));
    do {
        REP(i,100) {
            string eq1, eq2;
            eq1 = "((" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " " + to_string(nums[2]) +
            ") " + getRandomOperand() + " " + to_string(nums[3]);
            eq2 = "(" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " (" + to_string(nums[2]) +
            " " + getRandomOperand() + " " + to_string(nums[3]) + ")";
            if (isten(eq1)) {
                cout << eq1 << endl;
                return;
            }else if (isten(eq2)) {
                cout << eq2 << endl;
                return;
            }
        }
    }while (next_permutation(nums.begin(), nums.end()));
    cout << 0 << endl;
}

int main() {
    int a, b, c, d;
    while(cin >> a >> b >> c >> d, a + b + c + d) {
        solve41(a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int w[10], k[10];
  for(int i = 0; i < 10; i++)
    cin >> w[i];
  for(int i = 0; i < 10; i++)
    cin >> k[i];
  sort(w, w + 10);
  sort(k, k + 10);
  cout << w[7] + w[8] + w[9] << " " << k[7] + k[8] + k[9] << endl;
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	ll H, W; cin >> H >> W;
	ll ans;
	if (H == 1 || W == 1) {
		ans = 1;
	} else if (H % 2 == 1 && W % 2 == 1) {
		ans = (H * W + 1) / 2;
	} else {
		ans = H * W / 2;
	}
	cout << ans << endl;
}

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

typedef long long ll;
const int MAXN = 310;

int n, k, m, c[MAXN][MAXN];
int f[MAXN][MAXN], sum[MAXN][MAXN];

int main()
{
	scanf("%d %d %d", &n, &k, &m);
	c[0][0] = 1;
	for(int i = 1; i < MAXN; ++i)
	{
		c[i][0] = c[i][i] = 1;
		for(int j = 1; j < i; ++j) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % m;
	}
	for(int i = k; ~i; --i)
	{
		f[i][0] = 1;
		for(int j = 1; j <= n; ++j)
			for(int t = 0; t < j; ++t)
				f[i][j] = (f[i][j] + (ll)sum[i + 1][j - t - 1] * f[i][t] % m * c[j - 1][t]) % m;
		for(int j = 0; j <= n; ++j)
			sum[i][j] = (sum[i + 1][j] + f[i][j]) % m;
	}
	printf("%d\n", f[0][n]);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define N 500010
#define inf 0x3f3f3f3f
#define mp make_pair
using namespace std;
struct node
{
	int to,nxt,belong;
}e[N<<2];
int n,m,x,y,c,head[N<<2],cnt,d[N*2] ;
void ins(int u,int v,int c)
{
	e[++cnt].to=v;
	e[cnt].nxt=head[u];
	e[cnt].belong=c;
	head[u]=cnt;
}
std::set<int> st[N];
priority_queue<pair<int,int> > q;
void spfa()
{
	for (int i=1;i<=n;i++) d[i]=inf;
	d[1]=0;
	q.push(mp(0,1));
	while (!q.empty())
	{
		int u=q.top().second,ans=-q.top().first;
		q.pop();
		if (d[u]<ans) continue;
		for (int i=head[u];i;i=e[i].nxt)
		{
			int v=e[i].to;
			int num=ans+!st[u].count(e[i].belong);
			if (d[v]>num)
			{
				d[v]=num;
				q.push(mp(-num,v));
				st[v].clear();
				st[v].insert(e[i].belong);
			}
			else if (d[v]==num) st[v].insert(e[i].belong);
		}
	}
	if (d[n]==inf) cout<<"-1";
	else cout<<d[n];
}
int main()
{
	cin>>n>>m;
	for (int i=0;i<m;i++)
	{
		cin>>x>>y>>c;
		ins(x,y,c);
		ins(y,x,c);
	}
	spfa();
	return 0;
}

Measured memory_bytes: 42744
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  string s; cin>>s;
  Yn((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]));
}













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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

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

    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            MSG("OK")
            exit(0);
        }
    }

    MSG("NG")
}


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

signed main(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> vec[MAX];
	priority_queue<int> pq;
	rep(i, n) 
	{
		int a, b;
		cin >> a >> b;
		vec[a].push_back(b);
	}
	ll ans = 0;
	for(int i = 1; i <= m; i++)
	{
		rep(j, vec[i].size())
		{
			pq.push(vec[i][j]);
		}
		if (pq.size() == 0) continue;
		ans += pq.top(); pq.pop(); 
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LLI;

struct info{
	LLI rep;
	LLI value;
};

bool by_value(info & a, info & b)
{
	return a.value < b.value;
}

int main()
{
	LLI n, k, a, b;
	cin >> n >> k;
	
	info arr[n];
	for(int i = 0; i < n; i++)
	{
		cin >> a >> b;
		arr[i].rep = b;
		arr[i].value = a;
	}
	sort(arr,arr+n,by_value);
	
	for(int i = 0; i < n; i++)
	{
		if( k <= arr[i].rep )
		{
			cout << arr[i].value;
			break;
		}
		k -= arr[i].rep;
	}
	
	return 0;
}

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

int main(void){
    int N,cnt=0;
    cin>>N;

    for(int i=0;i<=20;i++){
        for(int j=0;j<=15;j++){
            if(4*i+7*j==N)
                cnt++;
        }
    }
    if(cnt>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int h,w;
  scanf("%d%d",&h,&w);
  int i,j;
  char s[51][51];
  for(i=0;i<h;i++){
    scanf("%s",s[i]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='#') printf("#");
      else{
        int count=0;
        if(s[i-1][j-1]=='#') count++;
        if(s[i-1][j]=='#') count++;
        if(s[i][j-1]=='#') count++;
        if(s[i+1][j-1]=='#') count++;
        if(s[i+1][j]=='#') count++;
        if(s[i+1][j+1]=='#') count++;
        if(s[i][j+1]=='#') count++;
        if(s[i-1][j+1]=='#') count++;
        printf("%d",count);
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

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

  std::vector<int> ds;
  for (int i=1; i<=N; i++) {
    int d;
    std::cin >> d;
    ds.push_back(d);
  }
  std::sort(ds.begin(), ds.end(), std::greater<int>());

  int prev = 101;
  int count = 0;
  for (auto d : ds) {
    if (d < prev) {
      count++;
      prev = d;
    }
  }

  std::cout << count << std::endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
int main()
{
	SPEED
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll ans;

	ans = max(a*c, max(b*d, max(b*c, a*d)));
	cout << ans;

	return 0;
}

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

const int INF = 1001001001;

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(){
    int n;
    cin >> n;
    vector<ll> h(n), dp(n, INF);
    rep(i, n) cin >> h[i];
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

int main() {
  int x,n;cin>>x>>n;
  int pn[101];rep(i,101)pn[i]=0;
  int p;
  rep(i,n) {
    cin>>p;
    pn[p]=1;
  }
  
  rep(d,100){
    if (x-d<1 || pn[x-d]==0) {
      cout<<x-d;return 0;
    }
    if (x+d>100 || pn[x+d]==0) {
      cout<<x+d;return 0;
    }
  }
}


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

int main() {
  ll N,C,K;
  cin >> N >> C >> K;
  vector<ll> T(N);
  rep(i,N){
    cin >> T.at(i);
  }
  ll bus = 0;
  sort(T.begin(),T.end());
  for( ll p = 0;p<N;p++){
    ll q = p;
    while(T.at(q) <= T.at(p) + K){
      q++;
      if(q - p == C){
        break;
      }
      if(q == N ){
        break;
      }
    }
    bus++;
    p = q - 1;
  }
  cout << bus << endl;
}
      

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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(){
    ll k,n;cin >> n >>k;
    vl a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    ll res=0;
    rep(i,30){
        if((1<<i)&k){
            ll t=1<<i;
            t--;
            ll p=(k-(1<<i))|t;
            ll sum=0;
            rep(j,n){
                if(p==(p|a[j]))sum+=b[j];
            }
            chmax(res,sum);
        }
    }
    ll sum=0;
    rep(j,n){
        if(k==(k|a[j]))sum+=b[j];
    }
    chmax(res,sum);
    cout << res <<endl;
}   

Measured memory_bytes: 4816
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int fa[100010],n,m,ans;
inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}

int main(){
	n=read(),m=read();ans=n;
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		x=find(x),y=find(y);
		if(x==y)continue;
		ans--;fa[x]=y;
	}cout<<--ans;
	return 0;
}


Measured memory_bytes: 3968
/* ABC115 */
/* A */
#include <iostream>
using namespace std;

int main(void)
{

  int D, diff;

  cin >> D;
  diff = 25 - D;

  string today;
  today = "Christmas";
  for (int i = 0; i < diff; i++)
  {
    today += " Eve";
  }
  cout << today;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b)                                                           \
  for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i) // ROF(i,n,0)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで降順
#define SUM(a) accumulate(all(a), int(0))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> T add(const T &a, const T &b) { return (a + b) % mod; }

signed main() {
  int n, m;
  cin >> n >> m;
  vvi g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vi checked(n), p(n, -1);
  checked[0] = 1;
  queue<int> st;
  st.push(0);
  while (not st.empty()) {
    int now = st.front();
    st.pop();

    for (auto next : g[now]) {
      if (checked[next] == 0) {
        checked[next] = 1;
        p[next] = now;
        st.push(next);
      }
    }
  }
  cout << "Yes" << endl;
  FOR(i, 1, n) { cout << p[i] + 1 << endl; }
}

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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(){
    ll h,w;
    cin >> h >> w;
    char grid[h][w];
    ll cnt = 0;
    for (ll i = 0; i < h;i++){
        for (ll j = 0; j < w; j++){
            cin >> grid[i][j];
            if (grid[i][j] == '#') cnt++;
        }
    }
    cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 3608
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();
    let c: u32 = iter.next().unwrap().parse().unwrap();

    println!("{}", std::cmp::min(b/a, c));
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  int n, k, s;
  cin >> n >> k >> s;

  rep(i, 0, n){
    if(i < k) cout << s;
    else if(s == 1 or s == 2) cout << s+1;
    else cout << s-1;
    cout << " \n"[i==n-1];
  }

  return 0;
}


Measured memory_bytes: 1280
#pragma warning(disable:4996)

#include<iostream>
#include<algorithm>
//#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define inf 0x7FFFFFFF
#define MOD 2147493647
#define moD 1000000003
#define pii pair<int,int>
#define eps 1e-7
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
const int maxn = 1e3 + 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
typedef  long long ll;
using namespace std;

char mp[10][10];	
int n, m, k;
int s1[10];
int s2[10];
int sum;

bool check(int x, int y) {
	vector<int> v1, v2;
	int ans = sum;
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	for (int i = 0; i < n; i++) {
		if (1 & (x >> i)) {
			ans -= s1[i]; v1.push_back(i);
		}
	}
	for (int j = 0; j < m; j++) {
		if (1 & (y >> j)) ans -= s2[j], v2.push_back(j);
	}
	for (int i = 0; i < v1.size(); i++) {
		for (int j = 0; j < v2.size(); j++) {
			if (mp[v1[i]][v2[j]] == '#') ans++;
		}
	}
	if (ans == k) return 1;
	else return 0;
}


int main() {
	int cnt = 0;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; i++) scanf("%s", mp[i]);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (mp[i][j] == '#') s1[i]++;
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			if (mp[j][i] == '#') s2[i]++;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (mp[i][j] == '#') sum++;
		}
	}
	//printf("%d %d %d\n", s1[0], s2[0], sum);
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < (1 << m); j++) {
			if (check(i, j)) cnt++;
		}
	}
	printf("%d", cnt);
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,cnt=0,sum=0;
	cin>>n;
	int a[2][n];
	int s[n];
	memset(s,0,sizeof(s));
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		s[i]=a[0][i]-a[1][i];
		if(s[i]>=0) cnt++,sum+=s[i];
		else continue;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int k = scanner.nextInt();
            int cnt = 0;
            for (int i = (int)Math.max(A,B); i >0; i--) {
                if (A % i == 0 && B % i == 0) {
                    if (++cnt == k) {
                        System.out.println(i);
                        break;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 23124
import os

def main():
	n,k = map(int, input().split())
	h_list = list(map(int, input().split()))
	count = 0

	for i in h_list:
		if k <= i:
			count += 1
		else:
			pass
	print(count)

if __name__ == "__main__":
	main()


Measured memory_bytes: 11912
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


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

  if (N >= 1000) cout << "ABD" << endl;
  else cout << "ABC" << endl;
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

const int M = 300005;

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

  int n;
  while (true) {
    cin >> n;
    if (n == 1) break;
    bool msprimes[M];
    fill(msprimes, msprimes + M, true);

    cout << n << ":";
    for (int i = 2; i <= n; i++) {
      if (i % 7 != 1 && i % 7 != 6) continue;

      if (msprimes[i]) {
        if (n % i == 0) cout << " " << i;
        for (int j = i * 2; j <= n; j += i) {
          msprimes[j] = false;
        }
      }
    }
    cout << "\n";
  }

  return 0;
}


Measured memory_bytes: 3428
#include<stdio.h>
#include<string.h>

int check(char a,char b){
  if((a=='i' && b=='i')||(a=='w' && b=='w')||(a=='(' && b==')')||(a==')' && b=='(')) return 0;
  else return 1;
}


int main(){
  char s[10];
  int length,odd,n,count;
  scanf("%s",s);
  length=strlen(s);
  odd=1;
  if(length%2==0){
    odd=0;
  }
  count=0;
  for(int i=0;i<length/2;i++){
    if(check(s[i],s[length-1-i])){
      count+=1;
    }
  }
  if(odd){
    if(s[length/2]!='i' && s[length/2]!='w'){
      count+=1;
    }
  }
  printf("%d\n",count);
}



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

int main() {
  size_t N, T;

  std::cin >> N >> T;

  bool tle = true;
  size_t ans = 1000;

  for (size_t i=0; i<N; i++) {
    size_t c, t;
    std::cin >> c >> t;

    if (t <= T) {
      ans = std::min(ans, c);
      tle = false;
    }
  }

  if (tle)
    std::cout << "TLE" << std::endl;
  else
    std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
	int n;
	scanf("%d", &n);
	int a[n];
	rep(i, n) scanf("%d", &a[i]);
	rep(i, n){
		if(a[i] % 2 == 0){
			if((a[i] % 3 != 0) && (a[i] % 5 != 0)){
				printf("DENIED");
				return 0;
			}
		}
	}
	printf("APPROVED");
	return 0;
}



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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,b*c),max(a*d,b*d));
    return 0;
}


Measured memory_bytes: 3540
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

pl p[100000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    rep(i,n) {
        ll x, l;
        cin >> x >> l;
        p[i].first = x+l;
        p[i].second = x-l;
    }
    sort(p, p+n);
    ll st = -linf;
    int ans = 0;
    rep(i,n) {
        if (st > p[i].second) continue;
        st = p[i].first;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  sort(ALL(a));

  ll ans = INF;
  ll tmp;
  FOR(i, a[0], a.back() + 1) {
    tmp = 0ll;
    REP(j, N) {
      //if (a[i] == a[j]) continue;
      tmp += (i - a[j]) * (i - a[j]);
    }
    ans = min(tmp, ans);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX_R 55
#define MAX_C 55
#define Endl endl

using Graph = vector<vector<int>>;

ll n,ans=0;

void dfs(ll sum, bool seven, bool five, bool three){
    if(sum > n) return;
    if(seven&&five&&three == true){
        ans++;
    }
    dfs(sum * 10 + 7, true, five, three);
    dfs(sum * 10 + 5, seven, true, three);
    dfs(sum * 10 + 3, seven, five, true);
}

int main() {
    cin >> n;
    dfs(0, false, false, false);
    cout << ans << endl;
}

Measured memory_bytes: 256
n, w = [ int(v) for v in input().split() ]
value_list = [ [ 0 for i in range(w+1) ] for j in range(n+1) ]
for i in range(1,n+1):
    a, b = [ int(v) for v in input().split() ]
    for j in range(a):
        value_list[i][j] = value_list[i-1][j]
    for j in range(a,w+1):
        value_list[i][j] = max(value_list[i-1][j],value_list[i-1][j-a]+b)

print(value_list[-1][-1])

Measured memory_bytes: 171528
r,c = map(int,input().split())
row=[]
for i in range(r):
	row.append(list(map(int,input().split())))

for i in range(r):
	row[i].append(sum(row[i]))

row.append([])


for j in range(c+1):
	sumc=0
	for i in range(r):
		sumc += row[i][j]
	row[r].append(sumc)
	
for i in range(r+1):
	print(" ".join(map(str,row[i])))




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

int main() {
    int H, W;

    while(1) {
        cin >> H >> W;
        if(H == 0 && W == 0)break;

        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                    cout << "#";
                }else {
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }

    return 0;
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	
	char s;
	for(int i=1;i<=n;i++){
		cin >> s;
		if(i == k){
			if(s == 'A'){
				cout << 'a';
			}else if(s == 'B'){
				cout << 'b';
			}else if(s == 'C'){
				cout << 'c';
			}
		}else{
			cout << s;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
def lscan; gets.split.map(&:to_i); end

gets
li = lscan

cnt = 0
li.each_cons(3) do |l|
  mx = l.max
  mi = l.min
  if (mx == l[0] || mx == l[2]) && (mi == l[0] || mi == l[2])
    cnt += 1
  end
end

p cnt

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <climits>
#include <algorithm>

using namespace std;

int a[100], b[100];
int memo[100][100]; 

int getMin(int l, int r)
{
	int ans = INT_MAX;
	
	if (l == r) return (0);
	if (memo[l][r] >= 0) return (memo[l][r]);
	
	for (int i = l; i < r; i++){
		ans = min(ans, getMin(l, i) + getMin(i + 1, r) + a[l] * b[i] * a[i + 1] * b[r]);
	}
	
	return (memo[l][r] = ans);
}

int main()
{
	int n;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		scanf("%d %d", &a[i], &b[i]);
	}
	memset(memo, -1, sizeof(memo));
	
	printf("%d\n", getMin(0, n - 1));
	
	return (0);
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll fish=1e9+7;
ll dp[1000005];
int N,K;
vector<ll> v;
ll Pow(ll x,ll y){
	x%=fish,y%=fish;
	ll ans=1,b=x;
	for (int qwq=y;qwq!=0;qwq/=2){
		if (qwq%2) ans=(ans*b)%fish;
		b=(b*b)%fish;
	}
	return ans;
}
void Pre(){
	v.clear();
	for (ll i=1;i*i<=N;i++){
		if (N%i==0){
			v.push_back(i);
			if (i*i!=N)
				v.push_back(N/i);
		}
	}
	sort(v.begin(),v.end());
}
int main(){
	//cout<<Pow(3,3)<<endl;
	while (cin>>N>>K){
			Pre();
		ll ans=0;
		for (int i=0;i<v.size();i++){
			dp[i]=Pow(K,(v[i]+1)/2);
			for (int j=0;j<i;j++){
				if (v[i]%v[j]==0)
					dp[i]=(dp[i]-dp[j]+fish)%fish;
			}
			if (v[i]%2==0)
				ans=(ans+(dp[i]*v[i]/2)%fish)%fish;
			else ans=(ans+(dp[i]*v[i])%fish)%fish;
		}
	printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f;
	cin>>n>>k;
	vc a(n);
	for(i=0;i<n;i++)cin>>a[i];
	ll low=1;ll high=*max_element(a.begin(),a.end()),mid,ans=MOD;
	while(high>=low)
	{
	    mid=(high+low)/2;
	    c=0;
	    for(auto x:a)
	        c+=(x-1)/mid;
	    if(c<=k)
	    {
	        ans=min(ans,mid);
	        high=mid-1;
	    }
	    else low=mid+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  int a[100005];
  int visited[100005] = {0};
  for(int i=1; i<=n; i++)
    scanf("%d", a+i);
  long ans = 0;
  for(int i=1; i<=n; i++){
    if(visited[i] || visited[a[i]])  continue;
    if(a[a[i]] == i){
      ans++;
      visited[a[i]] = visited[i] = 1;
    }
  }

  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N;
	int sum = 0, a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		sum += a - 1;
	}
	cout << sum << endl;
}


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

int main()
{
	ios::sync_with_stdio(0);

	long long n,m;
	cin>>n>>m;
	long long arr[n],sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}

	long double value = (long double)((long double)sum/(4.0 * (long double)(m)));
	long long count=0;

	for(int i=0;i<n;i++)
	{
		if(arr[i]>=value)
			count++;
	}

	if(count>=m)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

Measured memory_bytes: 3636