akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
signed main() {
    cin >> N;
    reps(i, 100000) {
        if (i * (i + 1) / 2 >= N) {
            reps(j, i) {
                if (i * (i + 1) / 2 - N == j) { continue; }
                cout << j << endl;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) (void)0
#endif


using namespace std;

inline long  toInt(string s) {long  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 T sqr(T x) {return x*x;}
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define long long long
long  pw(long  x, long  y){long  ans = 1;for(long  i = 0; i < y; i++){ans = ans * x;}return ans;}
long  factorial(long  x){long  ans = 1; for(int i = 1 ;i < x+1; i++){ans = ans *i;}return ans;}

long  permutation(long  x, long  y){return factorial(x)/factorial(x-y);}

//long combination(long x, long y){long ans = 1;if(y == 0){return 1;}	if(x-y < y){return combination(x,x-y);}for(long i = 0; i < y; i++){	ans *= (x-i);}	for(long i = 0; i < y; i++){ans /= (i+1);	}

#define MOD 1000000007
#define INF 1000000000000

template<class T1, class T2>
long Min(T1 a, T2 b){
    return (a > b ? b : a);
}
template<class T1, class T2>
long Max(T1 a, T2 b){
    return (a < b ? b : a);
}

int main(){
  long h,w,n;
  cin >> h >> w >> n;

  unordered_set<long> us;
  vector<long> a(n),b(n);
  for (long i = 0; i < n; i++){
    cin >> a[i] >> b[i];
    us.insert(a[i] * MOD + b[i]);
  }

  vector<long> ans(10,0);
  for (long i = 0; i < n; i++){
  vector<vector<int>> v(5,vector<int> (5,0));

    
    
    for(int k = -2; k <= 2; k++){
      for(int j = -2; j <= 2; j++){
	if(us.find((a[i]+k) * MOD + (b[i]+j))!= us.end()){
	  v[k+2][j+2] = 1;
	}
      }
    }
    dump(v);
    
    for(int k = 0; k < 3; k++){
      for(int j = 0; j < 3; j++){
	if(1 <= a[i] -2 + k && a[i] + k <= h && 1 <= b[i] - 2 + j && b[i] + j <= w){
	  
	  long cnt = 0;
	  for(int a = 0; a < 3; a++){
	    for(int b = 0; b < 3; b++){
	      if(v[k+a][j+b]) cnt++;
	    }
	  }
	  	ans[cnt]++;

	}

	
      }
    }

    dump(ans);
    
  }

  long tot = (w-2) * (h-2);

  long sum = 0;
  for(int i = 1; i < 10; i++){
    ans[i] /= i;
    sum += ans[i];
  }

  cout << tot - sum << endl;
  for(int i = 1; i < 10; i++){
    cout  <<  ans[i] << endl;

  }

  


}


Measured memory_bytes: 6052
#include<bits/stdc++.h>
using namespace std;
int main(){
	char ch;
	int counter[26]={};
	while( cin >> ch ){
		if(isupper(ch)) ch=tolower(ch);
		int num = ch - 'a';
		counter[num]++;
	}
	for(int i=0;i<26;i++){
		ch='a'+i;
		cout << ch << " : " << counter[i] << endl;
	}
}


Measured memory_bytes: 3068
#include<stdio.h>

int main(void){
  double left,right;
  int A_left=0, A_right=0;
  int B_left=0, B_right=0;
  int C_left=0, C_right=0;
  int D_left=0, D_right=0;
  while(scanf("%lf %lf",&left,&right)!=EOF){
    if(left>=1.1){ A_left++; }
    else if(left>=0.6 && left<1.1){ B_left++; }
    else if(left>=0.2 && left<0.6){ C_left++; }
    else if(left<0.2){ D_left++; }

    if(right>=1.1){ A_right++; }
    else if(right>=0.6 && right<1.1){ B_right++; }
    else if(right>=0.2 && right<0.6){ C_right++; }
    else if(right<0.2){ D_right++; }
  }
  printf("%d %d\n",A_left,A_right);
  printf("%d %d\n",B_left,B_right);
  printf("%d %d\n",C_left,C_right);
  printf("%d %d\n",D_left,D_right);

  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const ll MOD = 998244353;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const int MAX = 3000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    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;
    }
}
long long COM(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;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  COMinit();
  ll n,m;cin >>n >> m;
  ll ans = COM(3*m + n - 1 , n-1);
  FOR(i,2*m+1, 3*m+1){
      ll x = 3*m - i;
      ll tmp = n * COM(x + n - 2 , n - 2) % MOD;
      ans += MOD;
      ans -= tmp ;
      ans %= MOD;
  }
  FOR(i,m+1,n+1){
      if(3*m<i)break;
      if((3*m-i)%2==1)continue;
      ll eve = (3*m-i)/2;
      ll x = COM(n,i) * COM(eve + n - 1, n-1) % MOD;
      ans += MOD;
      ans -= x;
      ans %=MOD;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 70528
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 998244353

func mpow(a, b int) int {
	if b == 0 {
		return 1
	} else if b%2 == 0 {
		tmp := mpow(a, b/2)
		return tmp * tmp % mod
	}
	return mpow(a, b-1) * a % mod
}

var fracMemo = []int{1, 1}

func mfrac(n int) int {
	if len(fracMemo) > n {
		return fracMemo[n]
	}
	if len(fracMemo) == 0 {
		fracMemo = append(fracMemo, 1)
	}
	for len(fracMemo) <= n {
		size := len(fracMemo)
		fracMemo = append(fracMemo, fracMemo[size-1]*size%mod)
	}
	return fracMemo[n]
}

var ifracMemo = []int{1, 1}

func mifrac(n int) int {
	if len(ifracMemo) > n {
		return ifracMemo[n]
	}
	if len(ifracMemo) == 0 {
		fracMemo = append(ifracMemo, 1)
	}
	for len(ifracMemo) <= n {
		size := len(ifracMemo)
		ifracMemo = append(ifracMemo, ifracMemo[size-1]*mpow(size, mod-2)%mod)
	}
	return ifracMemo[n]
}

func nCr(n, r int) int {
	if n == r {
		return 1
	}
	if n < r || r < 0 {
		return 0
	}
	ret := 1
	ret *= mfrac(n)
	ret %= mod
	ret *= mifrac(r)
	ret %= mod
	ret *= mifrac(n - r)
	ret %= mod
	return (ret)
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B, C, D := getInt(), getInt(), getInt(), getInt()

	dp := make([][]int, C+1)
	for i := 0; i <= C; i++ {
		dp[i] = make([]int, D+1)
	}

	dp[A][B] = 1
	for i := A; i < C; i++ {
		dp[i+1][B] = (dp[i][B] * B) % mod
	}
	for i := B; i < D; i++ {
		dp[A][i+1] = (dp[A][i] * A) % mod
	}

	for i := A; i < C; i++ {
		for j := B; j < D; j++ {
			x := dp[i][j] * i * j
			dp[i+1][j+1] = (dp[i][j+1]*(j+1) +
				dp[i+1][j]*(i+1) - x) % mod
			if dp[i+1][j+1] < 0 {
				dp[i+1][j+1] += mod
			}
		}
	}
	// for i := 0; i <= C; i++ {
	// 	out(i, dp[i])
	// }
	out(dp[C][D])
}


Measured memory_bytes: 76852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << (b - a == c - b ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=(1<<21);
int n;
int a[maxn],dp[maxn][2];
int main(){
	scanf("%d",&n);
	for(register int i=0;i<(1<<n);i++){
		scanf("%d",&a[i]);
		dp[i][0]=i;
	}
	for(register int i=0;i<(1<<n);i++){
		for(register int j=0;i+(1<<j)<=(1<<n);j++){
			if(!(i&(1<<j))){
				int tmp=i|(1<<j);
				if(a[dp[tmp][0]]<a[dp[i][0]]){
					dp[tmp][1]=dp[tmp][0];
					dp[tmp][0]=dp[i][0];
				}
				else if(a[dp[tmp][1]]<a[dp[i][0]]&&dp[tmp][0]!=dp[i][0]){
					dp[tmp][1]=dp[i][0];
				}
				else if(a[dp[tmp][1]]<a[dp[i][1]]){
					dp[tmp][1]=dp[i][1];
				}
			}
		}
	}
	int ans=0;
	for(register int i=1;i<(1<<n);i++){
		ans=max(ans,a[dp[i][0]]+a[dp[i][1]]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 9216
from collections import deque

K = int(input())

lunlun = deque()

for i in range(1, 10):
    lunlun.append(i)

for i in range(K - 1):
    x = lunlun[0]
    lunlun.popleft()
    if x % 10 != 0:
        res = 10 * x + x % 10 - 1
        lunlun.append(res)
        
    res = 10 * x + x % 10
    lunlun.append(res)

    if x % 10 != 9:
        res = 10 * x + x % 10 + 1
        lunlun.append(res)
    

print(lunlun[0])

Measured memory_bytes: 11908
N,K=map(int,input().split())
MAX=2*(10**5)+1
P=10**9+7
"""A=[i for i in range(MAX)]
B=[0 for i in range(MAX)]
P=10**9+7
A[1]=1
print(len(A))
for i in range(1,MAX-1):
    A[i+1]=(A[i]*(i+1))%P
B[-1]=A[-1]
for i in range(0,MAX-1):
    B[MAX-i-2]=(B[MAX-i-1]*pow(MAX-i-1,P-2,P))%P"""

ans=0
for i in range(K,N+2):
    ans+=(2*N-i+1)*i//2 - (i-1)*i//2 + 1
    ans%=P
    #print((2*N-i+1)*i//2 - (i-1)*i//2 + 1)
print(ans)

Measured memory_bytes: 9192
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val K = rd.readInt()
    if (K%2 == 0) {
        println(-1)
        return
    }

    var ans = -1
    val L = if (K%7 != 0) K else K/7
    var num = 10L
    for (n in 1..10_000_000) {
        if (num % (L * 9) == 1L) {
            ans = n
            break
        }

        num *= 10L
        num %= L * 9
    }

    println(ans)
}


//val rd = debug.Reader("abc", "174", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 34752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n,ans=0;
  cin >> n;
  for(int i=1;i<=sqrt(n);i++){
    ans=max(ans,i*i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;
 
typedef pair<int, int> Pii;
 
void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
 
signed main(){
 
    int N;
    string S;
    cin >> N;
    cin >> S;
 
    int ans = 0;
 
    FOR(i, 1, N){
        string S1 = S.substr(0, i);
        string S2 = S.substr(i, N);
        int ans_tmp = 0;
        
        REP(j, 26){
            if(S1.find((char)('a' + j)) != string::npos && S2.find((char)('a' + j)) != string::npos) ans_tmp++;
        }
 
        if(ans_tmp > ans) ans = ans_tmp;
    }
 
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1001

int max(int a,int b){

 if(a>b)return a;

return b;
}



void func(int V[],int W[],int n,int w,int cnt){
int i,j;
int sum=0;
int vmax;
int dp[n+1][w+1];

/*-------初期化-------*/
for(i=0;i<=n;i++){
 for(j=0;j<=w;j++){
   dp[i][j]=-1;
 }
}
dp[0][0]=0;
/*--------------------*/

/*----------------------dp表の作成-----------------------------------*/
 for(i=1;i<=n;i++){
   for(j=0;j<=w;j++){
    if(dp[i-1][j]!=-1){
      dp[i][j]=max(dp[i-1][j],dp[i][j]);
      if(j+W[i]<=w)dp[i][j+W[i]]=max(dp[i-1][j]+V[i],dp[i][j+W[i]]);
    }
   }
 }
/*-------------------------------------------------------------------*/

vmax=-2;
for(j=0;j<=w;j++)vmax=max(vmax,dp[n][j]);
for(j=0;j<=w;j++)if(dp[n][j]==vmax)break;


i=n;
while(i!=0&&j!=0){

 if(dp[i][j]==dp[i-1][j])i--;

 else{
  sum+=W[i];
  j-=W[i];
  i--;
  
 }

}










printf("Case %d:\n",cnt);
printf("%d\n",vmax);
printf("%d\n",sum);
return;
}



int main(){
int n,i,w;
int W[MAX];
int V[MAX];
int cnt=0;

while(scanf("%d",&w)!=EOF){
 if(w==0)break;
 cnt++;
 scanf("%d",&n);
 for(i=1;i<=n;i++){
   scanf("%d,%d",&V[i],&W[i]);
 }

 func(V,W,n,w,cnt);

}

return 0;
}




Measured memory_bytes: 5624
def valid?(current, stride, n)
  return false if current > n
  diff = n - current
  diff % stride == 0
end

r, g, b, n = gets.split.map(&:to_i)
nums = [r, g, b]
nums = nums.sort.reverse
maxes = nums.map do |num|
  ((n + num - 1) / num).to_i
end
ans = 0
count = 0
while count <= n
  rest = n - count
  c2 = 0
  valids = []
  while c2 <= rest && valids.length < 2
    if valid?(c2 + count, nums[2], n)
      valids << c2
    end
    c2 += nums[1]
  end
  if valids.length == 1
    ans += 1
  elsif valids.length == 2
    diff = valids[1] - valids[0]
    r = rest - valids[1]
    ans += 2
    ans += (r / diff)
  end
  count += nums[0]
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	scanf("%d", &n);
	int ac = 0, wa = 0, tle = 0, re = 0;
	rep(i, n) {
		string c;
		cin >> c;
		if(c == "AC") ac++;
		else if(c == "WA") wa++;
		else if(c == "TLE") tle++;
		else if(c == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define f first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010


int main(){
	IOS;
	ll n,m;cin>>n>>m;
	ll a[n],l=1;
	rep(i,0,n){
		cin>>a[i];
		a[i]>>=1;
		l=(l*a[i])/(__gcd(l,a[i]));
	}
	bool ok=1;
	rep(i,0,n){
		ll val=l/a[i];
		if(val%2==0)ok=0;
	}
	if(!ok){
		cout<<0;
		return 0;
	}
	ll ans = m/l - m/(2*l);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 1024
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  h,w,i,j,count,x,y,sw,m,n:Integer;
  a,b:array of string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(x);
    Readln(y);

    Writeln((x+y) mod 24);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
n,y = map(int,input().split())
z= y//1000
a = 0
if z != y/1000:
  print(-1,-1,-1)
  exit()
  
for i in range(n+1):
  for j in range(n+1-i):
    k = n-i-j
    if k + 5*j + 10*i == z:
      print(i,j,k)
      exit()
    
      
  
print(-1,-1,-1)

Measured memory_bytes: 9124
import java.util.*;
 
class Main {
    static int count;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 1; i <= n; i++) map.put(i, new ArrayList<>());
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            map.get(a).add(b);
            map.get(b).add(a);
        }
        count = 0;
        HashSet<Integer> visited = new HashSet<>();
        visited.add(1);
        dfs(1, visited, map, n);
        System.out.println(count);
    }
    public static void dfs(int node, HashSet<Integer> visited, HashMap<Integer, ArrayList<Integer>> map, int n) {
        if (visited.size() == n) {
            count++;
            return;
        }
        ArrayList<Integer> nextNodes = map.get(node);
        for (int next: nextNodes) {
            if (visited.contains(next)) continue;
            visited.add(next);
            dfs(next, visited, map, n);
            visited.remove(next);
        }
    }
}


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

constexpr int64_t MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    vector<vector<int64_t>> dp(s.size() + 1, vector<int64_t>(4));
    dp[s.size()][3] = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        dp[i][3] = dp[i+1][3] * (s[i] == '?' ? 3 : 1) % MOD;
        for (int j = 2; j >= 0; j--) {
            dp[i][j] = (dp[i+1][j] * (s[i] == '?' ? 3 : 1)
                + dp[i+1][j+1] * (s[i] == '?' || s[i] == ('A' + j) ? 1 : 0)) % MOD;
        }
    }

    cout << dp[0][0] << endl;
}


Measured memory_bytes: 7424
<?php /*atcoder.php*/

$t = new temp();
$t->main();
unset($t);

class temp{
	private function arrayIn(){
		return explode(" ", fgets(STDIN));
	}

	public function main(){
		$in = $this->arrayIn();
		
		if(($in[0] + $in[1]) < $in[2]){
			echo "No";
		}else{
			echo "Yes";
		}

	}
	
}
?>


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	ll n, k; cin >> n >> k;
	vector<ll> a(n + 1, 0); 
	for (ll i = 1; i <= n; i++) cin >> a[i];

	vector<ll> num(n + 1, 0);
	vector<ll> firstVisitNum(n + 1, 0);

	ll cnt_cycle = 1;
	ll tmpIndex = 1;
	num[tmpIndex]++;
	
	while (true) {
		tmpIndex = a[tmpIndex];
		if (num[tmpIndex] == 0) {
			firstVisitNum[tmpIndex] = cnt_cycle;
		}
		num[tmpIndex]++;

		if (num[tmpIndex] == 2) {
			break;
		}
		cnt_cycle++;
	}

	cnt_cycle -= firstVisitNum[tmpIndex];

	if (firstVisitNum[tmpIndex] <= k) {
		k -= firstVisitNum[tmpIndex];
		ll targetIndex = k % cnt_cycle;
		ll p = targetIndex + firstVisitNum[tmpIndex];
		tmpIndex = 1;
		for (ll i = 0; i < p; i++) tmpIndex = a[tmpIndex];
		}
	else {
		tmpIndex = 1;
		for (ll i = 0; i < k; i++) tmpIndex = a[tmpIndex];
	}
	cout << tmpIndex << endl;
	return 0;
}

Measured memory_bytes: 8016
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
//----------------------------------------------------------------
void Main(){
  string s;
  cin>>s;
  int n = s.length();
  vl num(n);
  rep(i,n) num[i] = s[i]-'0';
  int pspo=s.length()-1;
  ll ans = 0;
  for(int i=0;i<1<<pspo;i++){
    bitset<12> plus(i);
    vl snum = num;
    for(int j=0;j<n-1;++j){
      if( plus[j] ){
        ans += snum[j];
      }else{
        snum[j+1] += 10*snum[j];
      }
    }
    ans += snum[n-1];
  }
  cout<<ans<<endl;
  return;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        s[i].resize(k);
        for (auto &e: s[i]) {
            cin >> e;
            --e;
        }
    }
    vector<int> p(m);
    for (auto &e: p) cin >> e;

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        bool f = true;
        for (int j = 0; j < m; ++j) {
            int cnt = 0;
            for (auto sid: s[j]) {
                if ((i >> sid) & 1) ++cnt;
            }
            if (cnt % 2 != p[j]) {
                f = false;
                break;
            }
        }
        if (f) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

uint64_t MOD = 1000000007;

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(x) begin(x),end(x)

using Weight = int64_t;
Weight INF = 1000000000000000000ll;
struct Edge {
	int src, dest; Weight weight;
	bool operator < (const Edge &rhs) const { return weight > rhs.weight; }
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_edge(Graph &g, int src, int dest, Weight weight) {
	g[src].push_back(Edge { src, dest, weight });
}

// Dijkstra (Verified: AOJ2005)
void dijkstra(Graph &g, Array &d, int s) {
	d.assign(g.size(), INF);
	d[s] = 0;
	using P = pair<Weight, int>;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	while (!que.empty()) {
		Weight dist = que.top().first;
		int v = que.top().second;
		que.pop();
		if (d[v] < dist) continue;
		REP(i, g[v].size()) {
			Edge e = g[v][i];
			if (d[e.dest] > d[v] + e.weight) {
				d[e.dest] = d[v] + e.weight;
				que.push(P(d[e.dest], e.dest));
			}
		}
	}
}

int main() {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	--s;
	--t;
	Graph g(n);
	REP(i, m) {
		int u, v, d;
		cin >> u >> v >> d;
		--u; --v;
		add_edge(g, u, v, d);
		add_edge(g, v, u, d);
	}
	Array d1;
	dijkstra(g, d1, s);
	Array d2;
	dijkstra(g, d2, t);
	Weight dist = d1[t];
	vector<pair<Weight, int>> v1;
	vector<pair<Weight, int>> v2;
	Graph mg1(n);
	Graph mg2(n);
	REP(i, n) {
		if (d1[i] + d2[i] == dist) {
			v1.emplace_back(d1[i], i);
			v2.emplace_back(d2[i], i);
			for (const auto& e : g[i]) {
				if (d1[e.dest] + d2[e.dest] == dist) {
					if (d1[e.dest] < d1[i]) {
						if (d1[e.dest] + e.weight == d1[i]) {
							add_edge(mg1, e.src, e.dest, e.weight);

						}
					}
					else {
						if (d1[i] + e.weight == d1[e.dest]) {

							add_edge(mg2, e.src, e.dest, e.weight);

						}
					}

				}
				
				
			}
		}
	}
	sort(ALL(v1));
	sort(ALL(v2));
	vector<uint64_t> dp1(n, 0);
	vector<uint64_t> dp2(n, 0);
	dp1[s] = 1;
	dp2[t] = 1;
	REP(i, v1.size()) {
		if (!i) continue;
		Weight d;
		int j;
		tie(d, j) = v1[i];
		for (const auto& e : mg1[j]) {
			dp1[j] += dp1[e.dest];
			dp1[j] %= MOD;
		}
	}
	REP(i, v2.size()) {
		if (!i) continue;
		Weight d;
		int j;
		tie(d, j) = v2[i];
		for (const auto& e : mg2[j]) {
			dp2[j] += dp2[e.dest];
			dp2[j] %= MOD;
		}
	}
	uint64_t cnt = dp1[t] * dp1[t];
	cnt %= MOD;
	REP(i, n) {
		if (d1[i] + d2[i] == dist) {
			if (d1[i] == d2[i]) {
				uint64_t mul = dp1[i] * dp2[i];
				mul %= MOD;
				mul *= mul;
				mul %= MOD;
				cnt += MOD - mul;
				cnt %= MOD;
			}
			for (const auto& e : mg2[i]) {
				if (d1[i] * 2 < dist && d1[e.dest] * 2 > dist) {
					uint64_t mul = dp1[i] * dp2[e.dest];
					mul %= MOD;
					mul *= mul;
					mul %= MOD;
					cnt += MOD - mul;
					cnt %= MOD;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 32072
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int a[2][n];
    rep(i, 0, n) cin >> a[0][i];
    rep(i, 0, n) cin >> a[1][i];
    
    rep(i, 1, n) a[0][i] += a[0][i - 1];
    a[1][0] += a[0][0];
    rep(i, 1, n) a[1][i] = max(a[0][i], a[1][i - 1]) + a[1][i];
    
    cout << a[1][n - 1] << endl;
    return 0;
}

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

int main(){
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K){
    for(int i = 0;i < S.size();i++){
      cout << S[i];
    }
  }else{
    for(int i = 0;i < K;i++){
      cout << S[i];
    }
    cout << "...";
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    bool ok=true;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='L'){
                ok=false;
            }
        }else{
            if(s[i]=='R'){
                ok=false;
            }
        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right;};//p == 親, l == 左子,r == 右子

Node T[MAX];
int n, D[MAX],H[MAX];

void setDepth(int u, int d) {//親から再帰的に深さを
	if( u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL)h1 = setHeight(T[u].left) + 1;
	if (T[u].right != NIL)h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2 );
}

int getSibling(int u) {
	if ( T[u].parent == NIL ) return NIL;//root
	if (T[T[u].parent].left != NIL && T[T[u].parent].left != u) return T[T[u].parent].left;
	if (T[T[u].parent].right != NIL && T[T[u].parent].right != u) return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if (T[u].parent == NIL) printf("root\n");
	else if( T[u].left == NIL && T[u].right == NIL )printf("leaf\n");
	else printf("internal node\n");

}



int main(){
	int v, l, r, root = 0;
	scanf("%d", &n);

	for ( int i = 0; i < n; i++) T[i].parent = NIL;

	for ( int i = 0; i < n; i++) {
		scanf("%d %d %d", &v,&l,&r);
		T[v].left = l;
		T[v].right = r;
		if ( l != NIL ) T[l].parent = v;
		if ( r != NIL ) T[r].parent = v;
	}

	for ( int i = 0; i < n; i++) if (T[i].parent == NIL) root =i;

	setDepth(root, 0);
	setHeight(root);

	for ( int i = 0; i < n; i++) print(i);
	return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <random>
#include <unordered_map>

using namespace std;

struct Point{
    double x,y;
    Point* next;
};

uint64_t toKey(int x, int y){
    union Key{
        uint64_t key;
        int x[2];
    };
    Key K;
    K.x[0]=x, K.x[1]=y;
    return K.key;
}

void build(unordered_map<uint64_t, Point*>& Grid, double d, int i, Point *P){
    Grid.clear();
    for(int j=0;j<=i;j++){
        int x=floor(P[j].x/d),y=floor(P[j].y/d);
        uint64_t key = toKey(x,y);
        if(Grid.count(key)!=0){
            P[j].next=Grid[key];
        }
        Grid[key]=&P[j];
    }
}

double distance(Point& a, Point &b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

double search(unordered_map<uint64_t, Point*>& Grid, double d, Point& P){
    int x=floor(P.x/d),y=floor(P.y/d);
    uint64_t key;
    double minimum=1e10;
    for(int dx=-1;dx<2;dx++){
        for(int dy=-1;dy<2;dy++){
            key=toKey(x+dx,y+dy);
            if(Grid.count(key)){
                Point *p=Grid[key];
                while(p!=NULL){
                    if(minimum>distance(*p,P)) minimum=distance(*p,P);
                    p=p->next;
                }
            }
        }
    }
    return minimum;
}

void insert(unordered_map<uint64_t, Point*>& Grid, double d, Point& P){
    int x=floor(P.x/d),y=floor(P.y/d);
    uint64_t key = toKey(x,y);
    if(Grid.count(key)!=0){
        P.next=Grid[key];
    }
    Grid[key]=&P;
}

int main(){
    int n;
    //cin >> n;
    scanf("%d",&n);
    Point P[n];
    for(int i=0;i<n;i++){
        //cin >> P[i].x >> P[i].y;
        scanf("%lf %lf",&P[i].x,&P[i].y);
        P[i].next=NULL;
    }
    //??????????????£???????????????
    random_device rd;
    mt19937 mt(rd());//?????????????????§?????????????????????????????????
    uniform_int_distribution<int> dist(0,n-1);
    for(int i=0;i<n;i++){
        int j = dist(mt);
        Point p = P[i];
        P[i]=P[j];
        P[j]=p;
    }
    unordered_map<uint64_t, Point*> Grid;
    double delta=distance(P[0],P[1]);
    build(Grid,delta,1,P);
    for(int i=2;i<n;i++){
        double d2=search(Grid,delta,P[i]);
        if(d2>=delta){
            insert(Grid,delta,P[i]);
        }else{
            delta=d2;
            build(Grid,delta,i,P);
        }
    }
    cout.precision(6);
    cout << fixed;
    cout << delta << endl;
    return 0;
}

Measured memory_bytes: 9336
from collections import deque

N = int(input())

graph = [[] for _ in range(N+1)]

for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))
    
Q, K = map(int, input().split())

visited = [-1 for _ in range(N+1)]

visited[K] = 0
que = deque()
que.append(K)

while (len(que)):
    now = que.popleft()
    
    for nxt, c in graph[now]:
        if(visited[nxt] != -1):
            continue
        visited[nxt] = visited[now]+c
        que.append(nxt)
        
for i in range(Q):
    x, y = map(int, input().split())
    print(visited[x]+visited[y])

Measured memory_bytes: 47464
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <stack>
#include <queue>

typedef long long ll;

using namespace std;

int main(void){
	int n; cin >>n;
	int a[100001];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	ll sum=0;
	int count=0, min_a=INT_MAX;
	for(int i=0; i<n; i++){
		sum += abs(a[i]);
		min_a = min(min_a, abs(a[i]));
		if(a[i] < 0) count++;
	}
	if(count%2 == 1)sum -= 2*abs(min_a);

	cout << sum << endl;
	
	return 0;
}

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

 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    cin>>n;
    ll arr[n];
    cin>>arr[0];
    ll max=0,flag=0,temp=0;
    for(i=1;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]-arr[i-1]==-1)
        {
            if(arr[i]>max)
            max=arr[i];
            

        }
        if(arr[i]-arr[i-1]<-1||arr[i]<max)
        {
        flag=1;
        }
        
    }

    if(flag==0)
    cout<<"Yes";
    else
    cout<<"No";


	return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
dic1,dic2=dict(),dict()
for i,x in enumerate(a):
    dic = dic1 if i%2==0 else dic2
    if x not in dic.keys():
        dic[x]=1
    else:
        dic[x]+=1
dic1=sorted(dic1.items(),key=lambda x:x[1])[::-1]
dic2=sorted(dic2.items(),key=lambda x:x[1])[::-1]

if dic1[0][0]!=dic2[0][0]:
    print(n-dic1[0][1]-dic2[0][1])
elif len(dic1)==1 and len(dic2)==1:
    print(n//2)
elif len(dic1)==1:
    print(n-dic1[0][1]-dic2[1][1])
elif len(dic2)==1:
    print(n-dic2[0][1]-dic1[1][1])
else:
    print(n-max(dic1[0][1]+dic2[1][1], dic2[0][1]+dic1[1][1]))

Measured memory_bytes: 19292
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n, h;
	int a[100000], b[100000];
	cin >> n >> h;
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}
	sort(a, a + n, greater<int>());
	sort(b, b + n, greater<int>());
	int k = 0;
	int j = 0;
	while(1){
		if(k < n && b[k] > a[0]){
			j += b[k];
			k++;
			if(j >= h){
				cout << k << endl;
				return 0;
			}
		}else{
			break;
		}
	}
	k += ((h - j - 1) / a[0] + 1);
	cout << k << endl;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

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

vector<int> x;
vector<int> y;


int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  cin >> a >> b;
  x.push_back(a);
  y.push_back(b);
  REP(i,n){
    cin >> a;
    x.push_back(a);
  }
  REP(i,m){
    cin >> b;
    y.push_back(b);
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if(x[x.size()-1] < y[0]) cout << "No War" <<endl;
  else cout << "War" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a=inf,z=-1;
  string s;
  cin >> s;
  rep(i,s.size()){
    if (s[i]=='A') a=min(a,i);
    if (s[i]=='Z') z=max(z,i);
  }
  cout << z-a+1 << endl;
}


Measured memory_bytes: 640
<?php
$stack=[];
$top=0;
$data=explode(' ',trim(fgets(STDIN)));
foreach($data as $d){
  if($d=='+') $stack[--$top]+=$stack[$top+1];
  elseif($d=='-') $stack[--$top]-=$stack[$top+1];
  elseif($d=='*') $stack[--$top]*=$stack[$top+1];
  else $stack[++$top]=$d;
}
echo $stack[$top];
?>

Measured memory_bytes: 15436
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
int n,ans=M;
char s[300005];
int es[300005],wsu[300005];
int main(void){
    scanf("%d %s",&n,s);
    for(int i=0;i<n;i++){
        if(s[i]=='E')es[i+1]++;
        else wsu[i+1]++;
        es[i+1]+=es[i];
        wsu[i+1]+=wsu[i];
    }
    for(int i=1;i<=n;i++){
        ans=min(ans,wsu[i-1]+es[n]-es[i]);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 2944
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int d;
    cin >> d;
    int cnt = 25 - d;

    string res = "Christmas";
    for (int i = 0; i < cnt; ++i) {
        res += ' ';
        res += "Eve";
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int H, W;
  string s[105];

  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    cin >> s[i];
  }

  string t = "";
  for (int i = 0; i < W+2; ++i) t += '#';

  cout << t << endl;
  for (int i = 0; i < H; ++i) {
    cout << '#' << s[i] << '#' << endl;
  }
  cout << t << endl;

  return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2 ;

    int dx = x2 - x1;
    int dy = y2 - y1;

    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;

    
}





//              g++ -std=c++1z


Measured memory_bytes: 760
#include<stdio.h>
 
int main(void)
{
    int m, f, r;
    while(1){
        scanf("%d %d %d",&m, &f, &r);
        if(m == -1 && f == -1 && r == -1){
            break; 
        }else if(m == -1 ||f == -1 ||f + m < 30){
            printf("F\n");
        }else if(m + f >= 80 ){
            printf("A\n");
        }else if(m + f >= 65 ){
            printf("B\n");
        }else if(m + f >= 50 ||r >= 50 ){
            printf("C\n");
        }else{
            printf("D\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

int main(void){
  ll n,m,x; cin >> n >> m >> x;
  ll c[n],a[n][m];
  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
  ll ans2 = 10e9+7;
  for(int i = 0; i < (1<<n); i++){
    ll rikaido[m];
    rep(i,m){
      rikaido[i] = 0;
    }
    ll check = 0;
    for(int j = 0; j < n; j++){
      if((i>>j)&1){
        rep(k,m) rikaido[k] += a[j][k];
        check += c[j];
      }
    }
    bool c = 1;
    rep(i,m){
      if(rikaido[i] < x) c = 0;
    }
    if(c) ans2 = min(ans2,check);
  }
  if(ans2 != 10e9+7) cout << ans2 << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }


    private void solve() {
        try {
            int n = sc.nextInt();
            int m = sc.nextInt();


            int left = 0;
            int right = 100001;

            for (int i = 0; i < m; i++) {
                int l = sc.nextInt();
                int r = sc.nextInt();
                if (l > left) left = l;
                if (r < right) right = r;
            }
            if (right - left < 0)
                System.out.println(0);
            else
                System.out.println(right - left  + 1);



        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 44324
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

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


Measured memory_bytes: 256