akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

void next(vector<int> &num, int m, int i,bool &end){
    if (i == -1)
    {
        end = 1 ;
    }
    else if (num.at(i) == m)
    {
        num.at(i) = 1 ;
        next(num,m,i-1,end) ;
    }else
    {
        num.at(i) ++ ;
        for (int j = i+1; j < num.size() ; j++)
        {
            num.at(j) = num.at(i) ;
        }
        
    }
    
    
}

int main(){
    int n,m,q ;
    cin >> n >> m >> q ;
    vector<vector<int> > s(q,vector<int>(4)) ;
    for (size_t i = 0; i < q; i++)
    {
        for (size_t j = 0; j < 4; j++)
        {
            cin >> s.at(i).at(j) ;
        }
        
    }
    vector<int> num(n,1) ;
    int ans = 0 ;
    int temp = 0 ;
    bool end = 0 ;
    int a,b,c,d ;
    while (end == 0)
    {
        temp = 0 ;
        for (size_t i = 0; i < q; i++)
        {
            a = s.at(i).at(0) ;
            b = s.at(i).at(1) ;
            c = s.at(i).at(2) ;
            d = s.at(i).at(3) ;
            if (num.at(b-1) - num.at(a-1) == c)
            {
                temp += d ;
            }
            
        }
        
        ans = max(ans,temp) ;
        
        next(num,m,n-1,end) ; 
    }
    cout << ans << endl ;
}

Measured memory_bytes: 3640
n, m = gets.split.map(&:to_i)
mod = 1_000_000_007
dp = Array.new(n + 2, 0)
a = []
dp[0] = 1
m.times do |i|
  a[i] = gets.to_i
  dp[a[i]] = -1
end
n.times do |i|
  next if dp[i] == -1
  if dp[i + 1] != -1
    dp[i + 1] += dp[i]
    dp[i + 1] %= mod
  end
  if dp[i + 2] != -1
    dp[i + 2] += dp[i]
    dp[i + 2] %= mod
  end
end
puts dp[n]


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

using namespace std;
using ll = long long;

int main()
{
  ll n = 0;
  ll ans = 0;

  cin >> n;

  ans = (n % 1000);

  if (ans) {

    cout << 1000 - ans << endl;

  } else {

    cout << ans << endl;
  }
}

Measured memory_bytes: 3632
import sys
import math
input = sys.stdin.readline
#str 注意
def main():
    n = int(input())
    root = int(math.sqrt(n))
    ans = 10**100
    for i in range(1,root+1):
        if n%i==0:
            ans = min(ans,i+n//i)
        else:
            pass
    print(ans-2)

if __name__=='__main__':
    main()

Measured memory_bytes: 39024
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

//void get(vector<int> &prime1, int max){
//	bool prime2[max+1];
//	prime2[1] = prime2[0] = false;
//	for(int a = 2; a<=max; a++){
//		prime2[a] = true;
//	}
//	if(max>=4){
//		for(int i=2; i<=sqrt((double)max); i++){
//			if(prime2[i]) {
//			for(int j=i; i*j<=max ;j++) 
//			{
//				for(int k = j*i; k<=max; k*=i)
//				prime2[k] = false;
//			}
//				
//			}
//		}
//	}
//	for(int x = 0; x<=max; x++){
//		if(prime2[x])
//		prime1.push_back(x);
//	}
//}

bool IsPrime(int max){
	for(int i = 2; i<=sqrt((double)max); i++)
	{
		if(max%i == 0)	return false;
	}
	return true;
}


int main(){
	int n;
	cin>>n;
	int count = 0;
	int max = 0;	
	int array[n];
	vector<int> prime1;
	for(int i=0; i<n; i++){
		cin>>array[i];
//		if(array[i]>max)
//		max = array[i];
		if(IsPrime(array[i]))
		count++;
	}
	
//	get(prime1, max);		
	
//	for(int i = 0; i<n; i++){
//		for(int j = 0; j<prime1.size(); j++){
//			if(array[i] == prime1[j])
//			count++;
//		}
//	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1196
s = input()
t = s[-1]
if t == '2' or t == '4' or t == '5' or  t == '7' or t == '9':
    print("hon")
if t == '0' or t == '1' or t== '6' or t == '8':
    print("pon")
if t == '3':
    print("bon")

Measured memory_bytes: 9072
x = int(input())
# n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
_max = 1
for i in range(1, x+1):
    for j in range(2, x+1):
        if pow(i, j) > _max and pow(i, j) <= x:
            _max = pow(i, j)
        if pow(i, j) > x:
            break

print(_max)


Measured memory_bytes: 2940
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    char ch;
    fr(r, h) fr(c, w) {
        cin >> ch;
        if (ch == '#') {
            a[r][c] = 1;
        }
    }
    vector<vector<int>> d(h, vector<int>(w));

    fr(r, h) fr(c, w) {
        if (r == 0 && c == 0) {
            d[r][c] = a[r][c];
            continue;
        }
        int up = inf, left = inf;
        if (r > 0) { 
            up = d[r-1][c];
            if (a[r-1][c] < a[r][c]) {
                ++up;
            }
        }
        if (c > 0) {
            left = d[r][c-1];
            if (a[r][c-1] < a[r][c]) {
                ++left;
            }
        }
        d[r][c] = min(up, left);
    }
    cout << d[h-1][w-1] << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MAXN 205
//#define N 262144
#define ULL unsigned long long
map<__int128,__int128> dp[2];
int a,b,c,d;
__int128 n;
void DP(__int128 x,__int128 tot=0){
    if(x>n*5)return ;
    if(dp[0].find(x)!=dp[0].end())return ;
    dp[1][x]=tot+n/x*d;
    dp[0][x]=tot+(n/x+1)*d;
    
    DP(x*2,tot+a);
    if(dp[0].find(x*2)!=dp[0].end()){
        __int128 pos=n%(x*2),neg=(x*2-n%(x*2));
        dp[0][x]=min(dp[0][x],dp[1][x*2]+(pos/x+1)*d);
        if(neg%x!=0)
        dp[0][x]=min(dp[0][x],dp[0][x*2]+(neg/x)*d);
        else
        dp[1][x]=min(dp[1][x],dp[0][x*2]+(neg/x)*d);
        dp[1][x]=min(dp[1][x],dp[1][x*2]+pos/x*d);
        if(neg%x!=0)
        dp[1][x]=min(dp[1][x],dp[0][x*2]+(neg/x+1)*d);
        else
        dp[0][x]=min(dp[0][x],dp[0][x*2]+(neg/x-1)*d);
    }
    DP(x*3,tot+b);
    if(dp[0].find(x*3)!=dp[0].end()){
        __int128 pos=n%(x*3),neg=(x*3-n%(x*3));

        dp[0][x]=min(dp[0][x],dp[1][x*3]+(pos/x+1)*d);
        if(neg%x!=0)
        dp[0][x]=min(dp[0][x],dp[0][x*3]+(neg/x)*d);
        else
        dp[1][x]=min(dp[1][x],dp[0][x*3]+(neg/x)*d);
        dp[1][x]=min(dp[1][x],dp[1][x*3]+pos/x*d);
        if(neg%x!=0)
        dp[1][x]=min(dp[1][x],dp[0][x*3]+(neg/x+1)*d);
        else
        dp[0][x]=min(dp[0][x],dp[0][x*3]+(neg/x-1)*d);
    }
    DP(x*5,tot+c);
    if(dp[0].find(x*5)!=dp[0].end()){
        __int128 pos=n%(x*5),neg=(x*5-n%(x*5));
        dp[0][x]=min(dp[0][x],dp[1][x*5]+(pos/x+1)*d);
        if(neg%x!=0)
        dp[0][x]=min(dp[0][x],dp[0][x*5]+(neg/x)*d);
        else
        dp[1][x]=min(dp[1][x],dp[0][x*5]+(neg/x)*d);
        dp[1][x]=min(dp[1][x],dp[1][x*5]+pos/x*d);
        if(neg%x!=0)
        dp[1][x]=min(dp[1][x],dp[0][x*5]+(neg/x+1)*d);
        else
        dp[0][x]=min(dp[0][x],dp[0][x*5]+(neg/x-1)*d);
    }
   // if(x==1000000000000000000)
    //printf("%lld %lld %lld %lld\n",(LL)x,(LL)dp[0][x],(LL)dp[1][x],(LL)tot);
}
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        LL N;
        scanf("%lld %d %d %d %d",&N,&a,&b,&c,&d);
        n=N;
        DP(1);
        printf("%lld\n",dp[1][1]);
        dp[0].clear();
        dp[1].clear();
    }
}

/*
1000000000000000000
1000000000000000000 1 1 1 1000000000
*/

Measured memory_bytes: 5664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == 'x') {
                count++;
            }
        }
        
        if (count > 7) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
int N;
int64_t dp[22][(1 << 21)];
bool A[21][21];

void init()
{
  for (int i = 0; i < 22; i++)
  {
    for (int j = 0; j < (1 << 21); j++)
    {
      dp[i][j] = -1;
    }
  }
}

int64_t rec(int i, int64_t bit)
{
  if (i == N)
  {
    return 1;
  }
  if (dp[i][bit] != -1)
    return dp[i][bit];
  int64_t ret = 0;
  for (int j = 0; j < N; j++)
  {
    if (A[i][j] && !(bit & (1 << j)))
    {
      (ret += rec(i + 1, (bit | (1 << j)))) %= MOD;
    }
  }
  return dp[i][bit] = ret;
}

int main()
{
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> A[i][j];
    }
  }
  init();
  cout << rec(0, 0) << endl;
}


Measured memory_bytes: 364064
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
def lcm(a,b):
    return a*b // gcd(a,b)
 
n = int(input())
t_list = []
result = 1
for t in range(n):
    result = lcm(result,int(input()))
print(result)

Measured memory_bytes: 3060
#include <iostream>
    #include <cmath>
    #include <iostream>
    #include <iomanip>
     
    using namespace std;
    int main(void){
        // Your code here!
        
        long long R;
        const double PI=3.14159265358979323846;
        
        cin >> R;
        
        cout << setprecision(15) << 2* double(R)*PI<<endl;
        return 0;
    }

Measured memory_bytes: 3740
#include <stdio.h>

int main()
{
   long long int b,c,x,y,flag=0,i,j,count,sum,max;
   
 char a[3][3];
 for(i=0;i<3;i++)
 {
     gets(a[i]);
 }
    printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
     return 0;
}


Measured memory_bytes: 128
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll n, m;
  cin >> n >> m;
  vll as(n);

  ll sum = 0;
  rep(i, n) {
    cin >> as[i];
    sum += as[i];
  }

  ll cnt = 0;
  rep(i,n){
    if(4*as[i]*m >= sum){
      cnt++;
    }
  }

  string ans = (cnt >= m) ? "Yes" : "No";


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		for (int i = 0; i < N; ++i) {
			int m, e, j; cin >> m >> e >> j;
			int ans = 0;
			if (m == 100 || e == 100 || j == 100) {
				ans = 0;
			}
			else if (m + e >= 180)ans = 0;
			else if (m + e + j >= 240)ans = 0;
			else if (m + e + j >= 210)ans = 1;
			else if (m + e + j >= 150 && (m >= 80 || e >= 80))ans = 1;
			else ans = 2;
			if (ans == 0)cout << 'A' << endl;
			else if (ans == 1)cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3016
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
ab.sort(key=lambda x:x[1])
time=0
for i in range(n):
    time+=ab[i][0]
    if time>ab[i][1]:
        print("No")
        exit()
print("Yes")


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

using namespace std;
using ll = long long;

ll gcd(ll n, ll m) { return !m ? n : gcd(m, n % m); }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    ll a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INfirst 1e18
#define EPsecond 1e-9
#define MOD 1000000007
 
// // for using in pairs
// #define first first
// #define second second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2> p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

// Utility functions.
void swap(int a, int b)
{
	int t = a;
	a = b;
	b = t;
}

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

void solve(int tc)
{
	int d, t ,s ;
	cin >> d >> t >> s;
	if (s * t >= d)
	{
		cout << "Yes\n";
	}else
	{
	cout << "No\n";
	}
}	

int32_t main()
{	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3644
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	//let N = parseInt(p[0]);//N
	const N = parseInt(p[0].split(" ")[0]);//N M
	const W = parseInt(p[0].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...
	
	let w = new Array(N);
	let v = new Array(N);
	//let c=new Array(N);
    //let z=new Array(N);
    for(let i=0;i<N;i++){
        let h = (p[i+1].split(" ").map(Number));
        w[i]=h[0];
        v[i]=h[1];
    }
    
    const maxv=100000;
	let m = new Array(N+1);
    //console.log(N,W,w,v);return;
    m[0]=new Array(maxv+1).fill(Infinity);
    m[0][0]=0;
    for(let i=0;i<=N;i++){
        m[i+1]=m[i].concat();
        for(let j=0;j<=maxv;j++){
            if(j-v[i]>=0){
                //console.log(m[i][j-w[i]]+v[i],m[i][j])
                m[i+1][j]=Math.min(m[i][j-v[i]]+w[i],m[i][j]);
            }
            
        }
        //console.log(i,m[i])
    }
	//console.log(m[N][maxv-1]);
	let i=maxv;
	while(m[N][i--]>W);//console.log(m[N][i--]);
	console.log(i+1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 121012
H, W = map(int, input().split())

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
memo = [[0]*W for i in range(H)]

S = []
for i in range(H):
    S.append(list(input()))

# print(S)

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            flag = False
            for n in range(4):
                if i+dy[n] > -1 and i+dy[n] < H and j+dx[n] > -1 and j+dx[n] < W:
                    if S[i+dy[n]][j+dx[n]] == '#':
                        flag = True

            if flag == False:
                print('No')
                exit()


print('Yes')



Measured memory_bytes: 3316
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long k = scanner.nextInt();
        long a = scanner.nextInt();
        long b = scanner.nextInt();
        System.out.println(k > a && b - a > 2 ? a + (k - a - 1) % 2 + (k - (k - a - 1) % 2 - a + 1) / 2 * (b - a) : k + 1);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>


using namespace std;


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(string, s);
	
	if (s.back() == 's') s += "es";
	else s += 's';
	
	otp(s);
	
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B;
    cin >> A >> B;
    if (B % A == 0) {
        cout << A+B << endl;
    } else {
        cout << B-A << endl;
    }
}

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

int main(){
  int n;
  cin >> n;
  vi h(n);
  rep(i,n) cin >> h[i];
  int ans = 0;
  int cnt = 0;
  rep(i,n-1){
    if(h[i] >= h[i+1]) cnt++;
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<long long int> A(N + 1, 0);
    vector<long long int> B(N, 0);
    for (int i = 0; i < N + 1; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    long long int cnt = 0;
    for (int i = 0; i < N; ++i) {
        cnt += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        A[i] -= min(A[i], B[i]);
        cnt += min(A[i + 1], B[i]);
        A[i + 1] -= min(A[i + 1], B[i]);
    }
    printf("%lld\n", cnt);
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll K, N, A[212345];

int main() {

	cin >> K >> N;
	rep(i, N) cin >> A[i];

	ll longest = K - A[N - 1] + A[0];

	rep(i, N - 1) longest = max(longest, A[i + 1] - A[i]);



	cout << K - longest << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    static int MAX = 300001;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            int key = array[i];
            if (!map.containsKey(key)) {
                map.put(key, 1);
            } else {
                int val = map.get(key);
                map.put(key, val + 1);
            }
        }
        
        COMinit();
        
        long[][] array2 = new long[300001][2];
        long sum = 0;
        for (Integer key : map.keySet()) {
            int val = map.get(key);
            
            long aa = (long)val * (val-1) / 2;
            long bb = (long)(val-1) * (val-2) / 2;
            
            array2[key][0] = aa;
            array2[key][1] = bb;
            sum += array2[key][0];
        }
        
        for (int i = 0; i < n; i++) {
            int key = array[i];
            System.out.println(sum - array2[key][0] + array2[key][1]);
        }
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    public static long nCkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 119940
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll N[200100];
ll preSumN[200100];
ll M[200100];
ll preSumM[200100];
int binarySearch(ll arr[],int low,int high,ll target){
    int mid;
    while(low<=high){
        mid=(low+high)/2;
        if(arr[mid]==target)
            return mid;
        else if(arr[mid]>target)
            high = mid-1;
        else
            low = mid+1;
    }
    return low;
}
int main(){
    int n,m,i;
    ll k,other;
    cin>>n>>m>>k;
    for(i=0;i<n;i++){
        cin>>N[i];
    }
    for(i=0;i<m;i++){
        cin>>M[i];
    }
    for(i=0;i<n;i++)
        preSumN[i+1] = preSumN[i]+N[i];
    for(i=0;i<m;i++)
        preSumM[i+1] = preSumM[i]+M[i];
    int total=0;
    for(i=0;i<=n;i++){
        other = k-preSumN[i];
        if(other < 0)
            continue;
        int j = binarySearch(preSumM,0,m,other);
        if(preSumM[j] > other || j > m)
            j--;
        total = max(total,i+j);
    }
    cout<<total;
    return 0;
}


Measured memory_bytes: 9856
#include <iostream>

using namespace std;

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

  for (int i = 0; i < n; ++i) {
    bool ok = true;
    for (int j = 0; i + j < n; ++j)
      if (a[i + j] != b[j])
        ok = false;
    if (ok) {
      cout << n + i << endl;
      return 0;
    }
  }
  cout << 2 * n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    int ans = x / (y+z);
    out(ans)

    return 0;
}

Measured memory_bytes: 256
function Main(input){
  //パラメータ受取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var H = Number.parseInt(inputStr[0]);
  var cnt = 0;
  var ans = 1;
  while ( H > 1 ){
    if (H <= 1){
      break;
    }
    //割り算処理
    H = Math.floor(H/2);
    cnt++;
    ans += Math.pow(2,cnt);
    //console.log(H,cnt,ans);
  }
  //回答出力
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

signed main(){

	lli n;
	cin>>n;

	vector<string> s(n);
	vector<lli> x(n);

	lli sum = 0;
	REP(i,0,n){
		cin>>s[i]>>x[i];
		sum += x[i];
	}
	
	string t;
	cin>>t;

	lli sumD = 0;
	REP(i,0,n){
		sumD += x[i];
		if(t == s[i])break;
	}

	cout<<sum-sumD<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {                                                                
    double x = 0, y = 0, v = 90;                                                
    double line, angle;                                                         
                                                                                
    while (scanf("%lf,%lf", &line, &angle), line || angle) {                    
        x += line * cos(M_PI * v / 180);                                        
        y += line * sin(M_PI * v / 180);                                        
        v -= angle;                                                             
    }                                                                           
    printf("%d\n%d\n", (int)x, (int)y);                                         
    return 0;                                                                   
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


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

}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;

int N, sum = 0;
vector<int> score;
vector<int> a;
bool dp[110][10100];

int main(){
   cin >> N;
   a.resize(N);
   REP(i,N){
       cin >> a[i];
       sum += a[i];
   }
   REP(i,N) REP(j,sum + 1) dp[i][j] = false;
   dp[0][0] = true;
   REP(i,N){
       REP(j,sum + 1){
           dp[i+1][j] |= dp[i][j];
           if(j >= a[i]) dp[i+1][j] |= dp[i][j - a[i]];
       }
   }
   int ans = 0;
   REP(i,sum + 1) if(dp[N][i] && i % 10 != 0) chmax(ans, i);
   cout << ans << endl;
}

Measured memory_bytes: 1280
# unionfind:連結成分が欲しい場合などに使用
import sys
sys.setrecursionlimit(10**9)

def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par_list[x] = get_par(par_list[x])
    return par_list[x]
def merge(x,y):
  par_x = get_par(x)
  par_y = get_par(y)
  if par_x != par_y:
    par_list[par_y] = par_x
    siz_list[par_x]+= siz_list[par_y]
def is_same(x,y):
  return get_par(x) == get_par(y)

N,Q=map(int,input().split())
par_list = list(range(N+1))
siz_list = [1]*(N+1)

for _ in range(Q):
  t,u,v=map(int,input().split())
  if t==0:
    merge(u,v)
  else:
    if is_same(u,v):
      print(1)
    else:
      print(0)

Measured memory_bytes: 17968
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

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

	int P = 0;
	string S;
	int N;

	cin >> S;
	N = (int)S.size();

	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'p')P++;
	}

	cout << N / 2 - P << endl;

	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 100020
using namespace std;

int gcd(int x, int y)
{
    return y ? gcd(y, x % y) : x;
}

int a[N];

int main(void)
{
    int n;
    int i;
    int o;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d", &a[i]);

    for(i = 1, o = a[0]; i < n; i ++)
        o = gcd(o, a[i]);
    printf("%d\n", o);

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b;
  int max=0;
  int ans=1;
  int man[100001];
  for(int i=0;i<100001;i++){
    man[i]=0;
  }
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a>>b;
    for(int j=a;j<=b;j++) man[j]++;
  }
  for(int i=2;i<=N+1;i++){
    if(man[i]>=i-1){
      ans=i;
    }
  }
  cout<<ans-1<<endl;
  return 0;
}



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

int right(int x){
  return x % 10;
}

int left(int x){
  while(10<=x){
    x /= 10;
  }
  return x;
}

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

  ll ans=0;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      ll c1=0, c2=0;
      for (int k = 1; k <= n; k++) {
	if(left(k)==i && right(k)==j){
	  c1++;
	} 
	if(left(k)==j && right(k)==i){
	  c2++;
	}
      }
      ans += c1*c2;
    }
  }

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
N = int(input())
A = [int(input())-1 for i in range(N-1)]
wins = [[] for _ in range(N)]

for i,a in enumerate(A):
    wins[a].append(i+1)

depth = [-1] * N
def dep(v):
    if len(wins[v])==0: return 0
    if depth[v] >= 0:
        return depth[v]
    ds = []
    for w in wins[v]:
        ds.append(dep(w))
    ds.sort(reverse=True)
    ret = 0
    for i,d in enumerate(ds):
        ret = max(ret, i+d+1)
    depth[v] = ret
    return ret
print(dep(0))

Measured memory_bytes: 123792
// https://beta.atcoder.jp/contests/abc111/tasks/arc103_b
#include <iostream>
#include <vector>
using namespace std;

bool odd(int n) {
    return n % 2 != 0;
}

int main()
{
    int N; cin >> N;
    vector<int> U(N), V(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        U[i] = x + y;
        V[i] = x - y;
    }
    for (int i = 0; i < N; i++) {
        if (odd(U[i]) != odd(U[0])) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> A(31);
    for (int i = 0; i < 31; i++) A[i] = 1 << (30 - i);
    if (!odd(U[0])) A.push_back(1);
    cout << A.size() << endl;
    for (int n : A) cout << n << " ";
    cout << endl;
    for (int i = 0; i < N; i++) {
        long long u = 0, v = 0;
        for (int j = 0; j < A.size(); j++) {
            bool uplus = u < U[i], vplus = v < V[i];
            cout << "LDUR"[uplus * 2 + vplus];
            u += (uplus ? +1 : -1) * A[j];
            v += (vplus ? +1 : -1) * A[j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()
c = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        c += bisect.bisect(l[j+1:], l[i]+l[j]-1)
print(c)

Measured memory_bytes: 50780
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	int b[n+1];
	for(int i=1;i<=n;i++)
	b[i]=0;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<b[i]<<endl;
	}
}

Measured memory_bytes: 5192
/*
!لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ
فَصَبْرٌ جَمِيلٌ
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define Rabe3_adel           file();
#define fr(x,y) for(int x=0; x<(y); ++x)
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	if (y == 1)return x;
	ll r = power(x, y / 2) % mod;
	return r%mod*r%mod*power(x, y % 2) % mod;
}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int main()
{

	Rabe3_adel
		string s;
	cin >> s;
	if (s == "ABC")cout << "ARC";
	else cout << "ABC";
}

Measured memory_bytes: 3564
MAX = 1.0 / 0.0
class Node
  attr_accessor :cf
  def initialize
    @cf = {}
  end
end

def dfs(s, t, g)
  stack = [[s, MAX]]
  done = {}
  done[s] = true
  while stack.size > 0
    u = stack[-1][0]
    return stack if u == t
    flag = true
    g[u].cf.each{|v, c|
      next if done[v]
      done[v] = true
      stack << [v, c]
      flag = false
      break
    }
    if flag
      stack.pop
    end
  end
  return nil
end

vn, e = gets.split.map(&:to_i)
g = Array.new(vn){Node.new}
e.times{
  u, v, c = gets.split.map(&:to_i)
  g[u].cf[v] = c
}

sum = 0
loop do
  #detect path from s to t
  path = dfs(0, vn-1, g)

  if path
    #maximum flow by the path is
    max = MAX
    path.size.times{|i|
      max = path[i][1] if max > path[i][1]
    }
    sum += max

    #subtract the flow
    (path.size-1).times{|i|
      s = path[i][0]
      t = path[i+1][0]
      g[s].cf[t] -= max
      g[t].cf[s] ||= 0
      g[t].cf[s] += max
      if g[s].cf[t] == 0
        g[s].cf.delete(t)
      end
    }
  else
    #there is no path
    break
  end
end

p sum

Measured memory_bytes: 9532
#include <stdio.h>

int main(void){

    int x, y, q, r;
    long long int a,b,z;

    while(scanf("%lld %lld", &a, &b)!=EOF){

    x = a;
    y = b;

    if(x < 0) x = -x;
    if(y < 0) y = -y;
    for(;;){
        q = x/y;
        r = x - q*y;
        if(r == 0) break;
        x = y;
        y = r;
    }
    z=a*b/y;
    printf("%d %lld\n",y,z);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int (i) = 1; i <= (n);++i)
using namespace std;

int main(){
    int X,Y;
    int cnt = 0;
    cin >> X >> Y;
    char board[60][60];
    for (int i = 1; i <= X; i++){
        for (int j = 1; j <= Y; j++) cin >> board[i][j];
    }

    for (int i = 1; i <= X; i++){
        for (int j = 1; j <= Y; j++){
            if (board[i][j] == '#' && board[i-1][j] != '#' && board[i+1][j] != '#' && board[i][j+1] != '#' && board[i][j-1] != '#') cnt++;
        }
    }
    if (cnt == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  string true_string = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i, S.size())
  {
    if (S[i] != true_string[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main() {

    ll n,h;
    cin>>n>>h;

    set<ll> a;
    vector<ll> b(n);


    ll am;
    rep(i,n){
        cin>>am>>b.at(i);
        a.insert(am);
    }

    am = *rbegin(a);
    sort(b.begin(),b.end(),greater<ll>());

    ll cob=0;
    ll co=0;
    while(h>0){
        if(am<=b.at(cob)){
            h -= b.at(cob);
            co++;
            if(cob!=n-1){
                cob++;
            }else{
                b.at(cob) = 0;
            }
        }else{
                if (h % am == 0) {
                    h = h / am;
                    co += h;
                    break;
                } else {
                    h = (h / am) + 1;
                    co += h;
                    break;
                }
        }
    }

    cout<<co<<endl;


}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1LL << 60;

struct Edge
{
    int to, rev, cap;
    Edge () {}
    Edge (int to, int rev, int cap) : to(to), rev(rev), cap(cap) {}
};

vector < Edge > G[107];
int N;
int itr[105];
int mc[105];

void add_edge(int a, int b, int c)
{
    G[a].push_back(Edge(b, G[b].size(), c));
    G[b].push_back(Edge(a, G[a].size() - 1, 0));
}
bool bfs(int s, int t)
{
    queue < int > que;
    memset(mc, -1, sizeof(mc));
    mc[s] = 0; que.push(s);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for(int i = 0; i < G[v].size(); i++) {
            Edge e = G[v][i];
            if(e.cap > 0 && mc[e.to] == -1) {
                mc[e.to] = mc[v] + 1;
                que.push(e.to);
            }
        }
    }
    return (mc[t] != -1);
}
int dfs(int v, int t, int f)
{
    if(v == t) return (f);
    for(int &i = itr[v]; i < G[v].size(); i++) {
        Edge &e = G[v][i];
        if(e.cap > 0 && mc[e.to] > mc[v]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return (d);
            }
        }
    }
    return (0);
}
int max_flow(int s, int t)
{
    int flow = 0;
    while(bfs(s, t)) {
        int f;
        memset(itr, 0, sizeof(itr)); 
        while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return (flow);
}
signed main()
{
    int sum = 0;
    cin >> N;
    for(int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        if(A < 0) {
            add_edge(0, i, -A);
        } else {
            sum += A;
            add_edge(i, N + 1, A);
        }
        for(int j = i + i; j <= N; j += i) add_edge(i, j, INF);
    }
    
    cout << sum - max_flow(0, N + 1) << endl;

    return (0);
}

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

int main(){
	int N;
  	int result = 0;
  	for (int i = 0 ; i < 3 ; i ++){
    	cin >> N;
      	result += N;
    }
  
  	if ( result >= 22){
    	cout << "bust" << endl;
    }else{
    	cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<queue>
using namespace std;
struct data{
    int t,s;
    data(int a,int b):t(a),s(b){}
    data(){}
};
int main(){
    int N,M;
    while(cin>>N>>M,N||M){
        int r;cin>>r;
        vector<data>V[10000];
        while(r--){
            int t,n,m,s;
            cin>>t>>n>>m>>s;
            m--;
            V[m].push_back(data(t,s));
        }
        //for(int i=0;i<M;i++)cout<<i<<":"<<V[i].size()<<endl;
        int q;
        cin>>q;
        while(q--){
            int ts,te,m;
            cin>>ts>>te>>m;
            m--;
            int imoss[2000]={0};
            //cout<<V[m].size()<<endl;
            for(int i=0;i<V[m].size();i++){
                data &d=V[m][i];
                if(d.s)imoss[d.t]++;
                else imoss[d.t]--;
                //cout<<d.t<<" "<<d.s<<endl;
            }
            for(int i=1;i<=1260;i++)imoss[i]+=imoss[i-1];
            int cnt=0;
            for(int i=ts;i<te;i++)if(imoss[i])cnt++;
            cout<<cnt<<endl;
        }
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int a = 0, b = 0, c = 0, d = 0;
  rep(i, 4) {
    int n;
    cin >> n;
    if (n == 1) {
      a++;
    } else if (n == 9) {
      b++;
    } else if (n == 7) {
      c++;
    } else if (n == 4) {
      d++;
    }
  }
  if ((a==1) && (b==1) && (c==1) && (d==1)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+1;
const ll INF=4e18;
void solve()
{
	ll N;
	cin>>N;
	ll h[maxn],dp[maxn];
	// dp[i]: denotes the minimum cost to reach ith position from
	// 		  1st position
	for(ll i=1;i<=N;i++)
	{
		cin>>h[i];
	}
	
	//Base Case
	dp[1]=0;	// minimum cost to stay in 1st position is 0
	dp[2]=abs(h[2]-h[1]);	// minimum cost to reach pos 2 from pos 1
	
	// Calculating dp[i]
	for(ll i=3;i<=N;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		// Frog can reach ith position from i-1 th pos or from
		// i-2 th pos.
		// Just take the best way of reaching ith pos.
	}
	cout<<dp[N]<<"\n";
	// Greedily going to the pos where h[pos]-h[i] is least does not
	// work.
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    /* 入力受け取り */
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    
    /* しゃくとり法 */
    long long res = 0;
    int right = 0;
    int sum = 0; // AND 和
    for (int left = 0; left < n; ++left) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            ++right;
        }
        res += right - left;
        if (left == right) ++right;
        else {
            sum -= a[left]; // a[left] を削除 (sum ^= a[left] でも OK)
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int l=0, r=0, flag=0, sz, sta=0, mar;
	string s;
	vector<int> v;

	cin>> s;
	sz=s.size();

	v.resize(sz);
	for(int i=0;i<sz;i++) v[i]=0;

	for(int i=0;i<sz+1;i++){
		if(s[i]=='R' && flag==1 || i==sz){
			v[mar-1]+=(r-1)/2+l/2+1;
			v[mar]+=r/2+(l-1)/2+1;
			r=1;
			l=0;
			flag=0;
			//cout<< v[mar-1] << " " << v[mar] << endl;
			//cout<< i << " " << sta << " " << mar << " " << v[mar-1] << " " << v[mar] <<endl;
			sta=i+1;
			continue;
		}
		if(s[i]=='R' && flag==0){
			r++;
			continue;
		}
		if(s[i]=='L' && flag==1){
			l++;
			continue;
		}
		if(s[i]=='L' && flag==0){
			l++;
			mar=i;
			flag=1;
			continue;
		}
	}

	for(int i=0;i<sz;i++) cout<< v[i] << " ";
	cout<< endl;

}

Measured memory_bytes: 1152