akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define INF 1111111111

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vl a(n);
  ll sum = 0;
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }
  ll snuke = a[0];
  ll ans = abs(2*snuke-sum);
	for(int i = 1; i < n-1; i++){
    snuke += a[i];
    ans = min(ans, abs(2*snuke-sum));
  }
  cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
x = int(input())
xyz = list(map(int, input().split()))
ans=0
xyz.sort(reverse=True)
for i in range(x):
    a=xyz[i]
    for j in range(i+1,x):
        b=xyz[j]
        if a>b:
            for k in range(j+1,x):
                c=xyz[k]
                if b>c:
                    if a+b>c and b+c>a and c+a>b:
                        ans+=1
print(ans)
                            
        

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

int main() {
    int M, D;
    cin >> M >> D;

    int count = 0;

    for(int i = 1; i < M+1; i++){
        for(int j = 1; j < D+1; j++){
            int d0 = j / 10;
            int d = j - (d0 * 10);

            if(d0 < 2 || d < 2){
                continue;
            }

            if(d0 * d == i){
                count++;
            }
        }
    }

    cout << count << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::iter;

fn main() {
    input!{
        a: usize,
        b: usize,
    }

    let sa: String = iter::repeat(a.to_string()).take(b).collect();
    let sb: String = iter::repeat(b.to_string()).take(a).collect(); 
    
    println!("{}", if a <= b { sa } else { sb });
}

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

using namespace std;




int main(void)
{

    string str,ans="";
    stack<char> sta;
    
    cin>>str;

    for(int i=0;i<str.size();i++){
        if(str[i] == 'B'){
            if(sta.size() >0){
                sta.pop();
            }
        }else{
            sta.push(str[i]);
        }
    }

    while(!sta.empty()){
        ans += sta.top();
        sta.pop();
    }
    reverse(ans.begin(),ans.end());


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


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll N;
  string s;
  cin >> N;
  s = to_string(N);

  rep(i, 3){
    if(s[i] == '7'){
      cout << "Yes" << "\n";
      return(0);
    }
  }
  cout << "No" << "\n";
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
	int N;
	cin >> N;
	int sum = 0;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		int cnt = 0;
		while(a % 2 == 0) {
			a /= 2;
			cnt++;
		}
		sum += cnt;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;
 
const MOD : u64 = 1_000_000_000 + 7;
 
fn main() {
    
    let n = read::<String>();
    //let a = (0..n).map(|_| { (0..n-1).map(|_| { read::<usize>() - 1 }).collect::<Vec<_>>() }).collect::<Vec<_>>();
    let ans = match &n[..] {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => "ERR"
    };
    
    println!("{}", ans);
}

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

using namespace std;

const int maxn = 3e5 + 2110;
const int mod = 1e9 + 7;
long long BIT[maxn];
long long ops[maxn];
int f[maxn];
vector <pair <long long, long long> > inters;
vector <long long> strt;
vector < pair<pair<long long, long long>, pair<long long, long long> > > v;
long long ans[maxn];
queue <pair<long long, long long> > que;
vector <pair<long long, long long> > a;
long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}

long long sum(int ind)
{
    ind++;
    long long s = 0;
    while (ind > 0)
    {
        s += BIT[ind];
        ind -= ind & (-ind);
    }
    return s;
}

void update(long long x, long long ind, long long sz)
{
    ind++;
    while(ind <= sz)
    {
        BIT[ind] += x;
        ind += ind & (-ind);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n, q, nn, mm;
    cin >> nn >> mm;
    n = mm + 1;
    for (int i = 0; i < nn; i++)
    {
        int t1, t2;
        cin >> t1 >> t2;
        f[t1]++;
        inters.push_back(make_pair(t1, t2));
    }
    sort(inters.begin(), inters.end());
    for (int i = 0; i < inters.size(); i++)
    {
        a.push_back(make_pair(inters[i].second, i));
        strt.push_back(inters[i].first);
    }
    long long hgt = 0;
    for (int i = 0; i <= mm; i++)
    {
        ops[i] = f[i] + hgt;
        hgt = ops[i];
    }
    long long g = 0;
    for (int i = 0; i < mm; i++)
    {
        long long cmt = ops[0];
        g++;
        for (int j = g; j <= mm; j += g)
        {
            long long yp = ops[j] - ops[j - g];
            cmt += yp;
            long long t, b, k;
            k = j;
            b = upper_bound(strt.begin(), strt.end(), j) - strt.begin();
            t = upper_bound(strt.begin(), strt.end(), j - g) - strt.begin();
            b--;
            if (b < t){continue;}
            v.push_back(make_pair(make_pair(k, i), make_pair(t, b)));
        }
        ans[i] = cmt;
    }
   	sort(v.begin(), v.end());
   	sort(a.begin(), a.end());
   	for (int i = 0; i < a.size(); i++){que.push(a[i]);}
   	for (int i = 0; i < v.size(); i++)
   	{
        int r = v[i].second.second;
        int l = v[i].second.first;
        int id = v[i].first.second;
        long long u = v[i].first.first;
        while(que.size() && que.front().first < u)
        {
            update(1, que.front().second, 302100);
            que.pop();
        }
        l--;
        if (l == -1){ans[id] -= sum(r); continue;}
        ans[id] -= (sum(r) - sum(l));
   	}


    //cout << ans[0] << endl;
    for (int i = 0; i < mm; i++){cout << ans[i] << endl;}
    return 0;
}














Measured memory_bytes: 96480
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

bool xor_same(ll a, ll b){
  REP(i,22){
    if(((a>>i)&1)&&(b>>i)&1){
      return false;
    }
  }
  return true;
}

int main(){
  ll n; cin >> n;
  ll a[n]; REP(i,n) cin >> a[i];
  ll r = 0;
  ll ans = 0;
  ll sum = 0;
  REP(l,n){
    while(r<n&&xor_same(sum,a[r])){
      sum += a[r];
      r++;
    }
    ans += r-l;
    if(r==l) r++;
    else sum -= a[l];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
package main

import (
    "bufio"
    "fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var S, W int
	fmt.Scan(&S,&W)
	if S <= W {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
	
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N;
vector<int> h;
queue<P> que;

void nextPair(int l, int r) {
    int nl = l;
    for (int nr = nl; nr <= r; ++nr) {
        if (h.at(nr) == 0) {
            if (nr != nl) {
                que.push(make_pair(nl, nr - 1));
            }
            nl = nr + 1;
        }
    }
    if (nl <= r) {
        que.push(make_pair(nl, r));
    }
}

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

    cin >> N;
    h.resize(N);
    for (auto &x : h) cin >> x;

    int ans = 0;
    nextPair(0, N - 1);
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        int l = p.first, r = p.second;
        int minh = INT_MAX;
        for (int i = l; i <= r; ++i) {
            minh = min(minh, h.at(i));
        }
        ans += minh;
        for (int i = l; i <= r; ++i) {
            h.at(i) -= minh;
        }
        nextPair(l, r);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int num;
    int c;
    int i;
    int j;
    int k;
    int l;


    c = 0;
    while(scanf("%d", &num) != EOF){
        for(i = 0; i < 10; i++){
            for(j = 0; j < 10; j++){
                for(k = 0; k < 10; k++){
                    for(l = 0; l < 10; l++){
                        if((i + j + k + l) == num){
                            c++;
                        }
                    }
                }
            }
        }
        printf("%d\n", c);
        c = 0;
    }

    return(0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n){
	for(int i = 2; i*i <=n; i++){
		if(n%i==0)return false;
	}	 
	return true;
} 
int main() {
   int n;
   cin >> n;
   while(!isPrime(n))n++;
   cout << n <<endl;
   return 0;
}


Measured memory_bytes: 256
N = input()

l = len(N)
ans = 0
#各桁を「数字無し（０）」「７（１）」「５（２）」「３（３）」で記述するような4進数を作る
for n in range(1, 4**l):
  n4 = ""
  while n > 0:
    mod = n % 4
    n4 = str(mod) + n4
    n //= 4
  
  if "0" in n4:
    continue
  
  if ("1" in n4) and ("2" in n4) and ("3" in n4):
    n4_10 = ""
    for i in range(len(n4)):
      if n4[i] == "1":
        n4_10 = n4_10 + "7"
      elif n4[i] == "2":
        n4_10 = n4_10 + "5"
      else:
        n4_10 = n4_10 + "3"
    if int(n4_10) <= int(N):
      ans += 1

print(ans)

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

int n, a, cnt[4];
double dp[305][305][305];

double f(int a, int b, int c){
    if (dp[a][b][c] > 0) return dp[a][b][c];
    if (!a && !b && !c) return dp[a][b][c] = 0;
    double ans = 0;
    if (a) ans += f(a-1, b+1, c)*a/(a+b+c);
    if (b) ans += f(a, b-1, c+1)*b/(a+b+c);
    if (c) ans += f(a, b, c-1)*c/(a+b+c);
    ans += (double)n/(a+b+c);
    return dp[a][b][c] = ans;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        cnt[a]++;
    }
    cout << fixed << setprecision(10) << f(cnt[3], cnt[2], cnt[1]) << "\n";
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}


ll modinv(ll a, ll m)
{
    return modpow(a, m - 2, m);
}

void modcomb(vec &c, ll n, ll k, ll m)
{
    vec inv(k+1, 0);
    inv[1] = 1;
    c[0] = 1; c[1] = n;
    REP(i,2,k+1) {
        inv[i] = m - inv[m%i] * (m / i) % m;
        c[i] = (((c[i-1] * (n - i + 1)) % m) * inv[i]) % m;
    }
}


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

    ll M = MIN(K,N-1);
    vec C(N, 0);
    modcomb(C, N-1, M, MOD);

    ll sum = 0;
    REP(i,0,M+1) {
        sum = (sum + (modpow(C[i], 2, MOD) * modinv(N-i, MOD)) % MOD) % MOD;
    }
    sum = (sum * N) % MOD;

    PR(sum);


    return 0;
}

/*



*/

Measured memory_bytes: 6428
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


int main(){
    int a,b,c,k;
    cin >> a >> b>> c >>k;
    bool d;
    int cnt=0;
    if(a<b){
    while(b>=c){
        cnt++;
        c*=2;
    }
    }
    else if(a>=b){
        while(a>=b){
            cnt++;
            b*=2;
        }
        while(b>=c){
            cnt++;
            c*=2;
        }
    }
    if(cnt<=k)d=true;
    else d=false;
    if(d)cout << "Yes" << endl;
    else cout << "No" << endl;
    }

    

Measured memory_bytes: 3632
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	A1 := getInt()
	A2 := getInt()
	A3 := getInt()

	if A1 + A2 + A3 >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

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

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

struct st_attack {
    int score;
    int cost;
};

int main(void) {
    int h,n;
    int max_score = 0;
    unsigned long long min_cost = __UINT64_MAX__;
    unsigned long long *costs;
    struct st_attack *attacks;
    scanf("%d %d", &h, &n);

    attacks = malloc( sizeof(struct st_attack)*n );
    for(int i=0; i<n; i++) {
        scanf("%d %d", &(attacks+i)->score, &(attacks+i)->cost);
        if( max_score < (attacks+i)->score ) {
            max_score = (attacks+i)->score;
        }
    }

    costs = malloc( sizeof(unsigned long long)*(h+max_score));
    
    for(int i=0; i<(h+max_score); i++) {
        costs[i] = __UINT64_MAX__;
    }
    costs[0] = 0;

    for(int i=0; i<h; i++) {
        if( costs[i]!=__UINT64_MAX__ ) {
            for(int j=0; j<n; j++) {
                if( costs[i+(attacks+j)->score] > costs[i] + (attacks+j)->cost ) { 
                    costs[i+(attacks+j)->score] = costs[i] + (attacks+j)->cost; 
                }
            }
        }
    }

    for(int i=0; i<max_score; i++) {
        if( costs[h+i]<min_cost ) {
            min_cost = costs[h+i];
        }
    }

    printf("%llu\n", min_cost);
    free(attacks);
    free(costs);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
const int N=1e5+5;
int n,m,from[N],to[N],fa[N],size[N],rec[N],cnt;
/**/
inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
signed main()
{
	// freopen("test.in","r",stdin);
	// freopen("test.out","w",stdout);
	read(n);read(m);
	for(int i=1;i<=m;i++)
	{
		read(from[i]);
		read(to[i]);
	}
	for(int i=1;i<=n;i++) fa[i]=i,size[i]=1;
	int ans=n*(n-1)/2;
	rec[++cnt]=ans;
	for(int i=m;i;i--)
	{
		int u=find(from[i]),v=find(to[i]);
		// cout<<fa[u]<<' '<<fa[v]<<' '<<size[u]<<' '<<size[v]<<'\n';
		if(u==v) {rec[++cnt]=ans;continue;}
		fa[u]=v;
		ans-=size[u]*size[v];
		size[v]+=size[u];size[u]=0;
		rec[++cnt]=ans;
	}
	for(int i=m;i;i--) cout<<rec[i]<<'\n';
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

const int N = 1e3, M = 1e9+7;
int add(int a, int b){ return a+b < M ? a+b : a+b-M; }
bool a[N][N];
int dp[N][N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,m; cin >> n >> m;
    forn(i,n) forn(j,m){
        char c; cin >> c;
        a[i][j] = c == '.' ? 1:0;
    }
    dp[n-1][m-1] = 1;
    dforn(i,n) dforn(j,m) if(a[i][j]){
        if(i == n-1 && j == m-1) continue;
        int x = i+1 < n && a[i+1][j] ? dp[i+1][j] : 0;
        int y = j+1 < m && a[i][j+1] ? dp[i][j+1] : 0;
        dp[i][j] = add(x,y);
    }
    cout << dp[0][0] << endl;
    return 0;
}


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

int main(){
    int N, X;
    cin >> N >> X;
    int D = 0;
    int res = 1;
    for(int i =0; i < N; i++){
        int L;
        cin >> L;
        D += L;
        if(D <= X) res ++;
    }
    cout << res << endl;
}

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

using namespace std;


vector<int> primes;

void allPrimes() {
        vector<bool> isPrime(1000000, true);
        for (int i = 2; i<1000000; i++) {
                
                if (isPrime[i]) {
                        primes.push_back(i);
                        for (int j=2*i; j<1000000; j += i) {
                                isPrime[j] = false;
                        }
                }
        }
}

int solver(int n) {
        int minus = 0;
        if (binary_search(primes.begin(), primes.end(), n)) minus = 1;
        return upper_bound(primes.begin(), primes.end(), 2 * n) - lower_bound(primes.begin(), primes.end(), n) - minus;

}

int main() {
        allPrimes();

        while (1) {
                int n; cin >> n; if (n==0) break;
                cout << solver(n) << endl;
        }
}

Measured memory_bytes: 1712
#include <iostream>
#include <cstdio>
using namespace std;
 
int main() {
	int pasta = 2001, juice = 2001;
 
	for(int i = 0; 3 > i; i++){
		 int buf;
		 scanf("%d", &buf);
		 if(buf < pasta) pasta = buf;
	}
	for(int i = 0; 2 > i; i++){
		 int buf;
		 scanf("%d", &buf);
		 if(buf < juice) juice = buf;
	}
 
	printf("%d\n", juice+pasta-50);
	return 0;
}

Measured memory_bytes: 1184
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> t(n), a(n);
	rep(i, n)cin >> t[i];
	rep(i, n)cin >> a[i];
	vector<ll> h(n);
	h[0] = t[0];
	rep(i, n - 1)if (t[i + 1] > t[i])
	{
		if (t[i + 1] <= a[i + 1])h[i + 1] = t[i + 1];
		else
		{
			cout << 0 << endl;
			return 0;
		}
	}
	if (h.back() != 0 && h.back() != a.back())
	{
		cout << 0 << endl;
		return 0;
	}
	h.back() = a.back();
	rrep(i, n - 1)if (a[i] > a[i + 1])
	{
		if (h[i] == 0)
		{
			if (a[i] <= t[i])h[i] = a[i];
			else
			{
				cout << 0 << endl;
				return 0;
			}
		}
		else if (h[i] != a[i])
		{
			cout << 0 << endl;
			return 0;
		}
	}
	ll MOD = 1e9 + 7;
	ll res = 1;
	rep(i, n)
	{
		if (h[i] != 0)continue;
		res *= min(t[i], a[i]);
		res %= MOD;
	}
	cout << res << endl;
}


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

const int MAX = 1000000;
const int MOD = 1000000007;

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

template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF = 1LL << 60;

int main() {
    ll K, T;
    cin >> K >> T;
    vector<ll> a(T);
    rep(i, T) { cin >> a[i]; }
    sort(a.begin(), a.end(), greater<ll>());
    cerr << a[0] << endl;
    cout << max(a[0] - 1 - (K - a[0]), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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(int argc, char const *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) puts("bust");
  else
    puts("win");
  return 0;
}

Measured memory_bytes: 3544
import java.util.Scanner;
public class Main{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int I=1;
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			double x[]=new double[n+1];
			double y[]=new double[n+1];
			double S=0;
			int i;
			for(i=0;i<n;i++)
			{
				x[i]=in.nextDouble();
				y[i]=in.nextDouble();
			}
			x[i]=x[0];
			y[i]=y[0];
			for(int j=0;j<i;j++)
			{
				double seki=(x[j]-x[j+1])*(y[j]+y[j+1]);
				S+=seki;
			}
			System.out.printf(I+++" "+"%.1f\n",Math.abs(S/2));
		}
	}
}

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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define Ld long double

using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main(){
    optimize();
    ll n;
    cin>>n;
    vector<ll> arr(n);
    FOR(i,0,n-1) cin>>arr[i];

    ll sum = 0;
    ll prefixSum = 0;

    FOR(i,0,n-1)
    {
        sum += prefixSum*arr[i];
        prefixSum += arr[i];
        prefixSum %= mod;
        sum %= mod;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4728
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
string s[maxn];
int main()
{
	int n;
	int d=0,a=0,b=0,ab=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<s[i].size();j++)
		{
			if(s[i][j-1]=='A'&&s[i][j]=='B')
			{
				d++;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(s[i][0]=='B') b++;
		if(s[i][s[i].length()-1]=='A') a++;
		if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A') ab++;
	}
	int ans=0;
	ans=d+min(b,a);
	if(b==a&&b==ab&&b!=0) ans--;
//	cout<<a<<" "<<b<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
open List
let i_inp : unit -> int = fun () ->
  int_of_string (input_line stdin)

let i_inp_list : unit -> int list = fun () ->
  let inp_split = Str.split (Str.regexp " ") (input_line stdin) in
  map (fun x -> int_of_string x) (inp_split)

(* inp_loop i_inp_list 10  のように使う *)
let rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->
  if n = 0 then []
  else
    let x = inp_fun () in
    x :: inp_loop inp_fun (n - 1)

let () =
  let n = i_inp () in
  let list =
    inp_loop
      (fun () ->
        let [a; b] = i_inp_list ()
        in (a, b))
      n in
  let list = fast_sort
               (fun (a1, b1) (a2, b2) -> if (b1, a1) > (b2, a2) then 1 else if (a1, b1) = (a2, b2) then 0 else -1)
               list in
  let rec loop t list =
    match list with
      [] -> true
    | (a, b) :: rest ->
       if t + a > b then false
       else loop (t + a) rest
  in
  if loop 0 list then
    print_endline "Yes"
  else
    print_endline "No"


Measured memory_bytes: 28824
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n, t;
int a[3010], b[3010];

int dp[3010][3010][3];
bool memo[3010][3010][3];

int f(int x, int y, int z)
{
    if(x == n) return 0;
    if(memo[x][y][z]) return dp[x][y][z];
    int ans = f(x+1, y, z);
    if(y >= a[x]) ans = max(ans, b[x] + f(x+1, y-a[x], z));
    if(!z) ans = max(ans, b[x] + f(x+1, y, 1));
    memo[x][y][z] = 1;
    dp[x][y][z] = ans;
    return ans;
}

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> t;
    forn(i, n) cin >> a[i] >> b[i];
    cout << f(0, t-1, 0);
}


Measured memory_bytes: 132096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();

		int num = Integer.parseInt(N);

		int xx = 0;
		for(int i = 0; i < N.length(); i++) {
			String a = N.substring(i, i+1);
			xx += Integer.parseInt(a);
		}

		if(num % xx == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21972
x = int(input())
x11 = x/11
num = [1,2,3,4,5,6]
num2= [7,8,9,10]

if x in num:
  print(1)
  exit()
elif x in num2:
  print(2)
  exit()

elif int(x11) == x11:
  print(int(x11)*2)
  exit()
elif x > int(x11)*11 + 6:
  print(int(x11)*2 +2)
  exit()
else:
  print(1+int(x11)*2)
  exit()


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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

int main(void){
  int r;
  int ans = 0;

  cin >> r;
  reps(i, 1, r){
    if (0 <= i & i < 10) ans++;
    else if(100 <= i && i < 1000) ans++;
    else if(10000 <= i && i < 100000) ans++;

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
INF = pow(10, 9)


def chmin(a, b):
    """

    :rtype: (int, boolean)
    """
    if a > b:
        return b, True
    return a, False


N = int(input())
H = [int(h) for h in input().split()]

dp = [INF for _ in range(N)]


if __name__ == '__main__':
    dp[0] = 0
    for i in range(1, N):
        dp[i], _ = chmin(dp[i], dp[i-1] + abs(H[i] - H[i - 1]))
        if i > 1:
            dp[i], _ = chmin(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]))
    print(dp[-1])


Measured memory_bytes: 13976
#include<bits/stdc++.h>
using namespace std;
bool judge(int x)
{
    int ans=0;
    while(x) x/=10,ans++;
    return ans&1;
}
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(judge(i)) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll H(N);
        rep(i, 0, N) cin >> H[i];

        ll std = H[0];
        ll ans = 0;
        rep(i, 0, N) {
                if (H[i] >= std) {
                        ++ans;
                        std = H[i];
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;


int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int n, i;
    string s;
    cin>>n>>s;
    int x = 0;
    int max = 0;

    fo(i, n) {
        if(s[i] == 'I') {
            x++;
            if(max<x)
                max = x;
        }
        if(s[i] == 'D') {
            x--;
            if(max<x)
                max = x;
        }
    }

    if(max<x)
        max = x;

    cout<<max;


return 0;
}

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

int gcd (int a, int b){
  if (a < b) swap (a, b);
  if (a % b == 0) return b;
  else gcd (b, a % b);
}

signed main() {
  int n;
  cin >> n;
  int a[100010];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int ans = a[0];
  for (int i = 1; i < n; i++){
    ans = gcd (ans, a[i]);
  }
  
  cout << ans << endl;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 1e5;
vi adj[2*N+1];
bool visited[2*N+1];
int u, v;

void dfs(int x) {
	visited[x] = true;
	if (x <= N) ++u;
	else ++v;
	for (int y : adj[x])
		if (!visited[y]) dfs(y);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		y += N;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	ll answer = 0;
	for (int x = 1; x <= N; x++) {
		if (visited[x]) continue;
		u = 0, v = 0;
		dfs(x);
		answer += (ll)u * v;
	}
	printf("%lld\n", answer - n);
}


Measured memory_bytes: 10240
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

n,m = li()
MOD = 10**9 + 7

if m > n:
    n, m = m, n
    
fac = fact(n,MOD)

if n-m > 1:
    print(0)

elif n-m == 1:
    print((fac[n] * fac[m]) % MOD)
    
else:
    print((2 * fac[n] * fac[m]) % MOD)
        
    

Measured memory_bytes: 7124
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

/**
 * @author Rimi
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String n = sc.next();

		String a  = n.substring(0 , 1);
		String b  = n.substring(1 , 2);
		String c  = n.substring(2 , 3);

		if(a.equals("1")) {
			a = "9";
		}else {
			a = "1";
		}
		if(b.equals("1")) {
			b = "9";
		}else {
			b = "1";
		}
		if(c.equals("1")) {
			c = "9";
		}else {
			c = "1";
		}

		System.out.print(a);
		System.out.print(b);
		System.out.print(c);

	}

}

Measured memory_bytes: 21712
N = int(input())
A = [int(input()) for i in range(N)]

if A[0] != 0:
    print(-1)
elif sum(A) == 0:
    print(0)
else:
    nonzero = []
    for i in range(1,N):
        if A[i] - A[i-1] > 1:
            print(-1)
            break
        if A[i] != 0:
            nonzero.append(A[i])
    else:
        ans = nonzero[0]-1
        for i in range(1,len(nonzero)):
            if nonzero[i-1] + 1 != nonzero[i]:
                ans += nonzero[i]-1
        print(ans+len(nonzero))
                

Measured memory_bytes: 101208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define orep(i, n) for (int i = 1; i < (int)(n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AServalVsMonster {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, a;
	    in >> h >> a;
	    out << ceill(h, a) << endl;
	}
};


int main() {
	AServalVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int M, N, M_; 
int seg[262200], lazy[262200]; 
void init(int M_){
	M = 1; 
	while(M < M_) M *= 2; 
	for(int i = 0; i < M * 2 - 1; i++){
		seg[i] = 0; lazy[i] = 0;  
	}
}
void update(int k){
	if(lazy[k] == 0) return; 
	seg[k] += lazy[k]; 
	if(k * 2 + 2 < M * 2 - 1){
		lazy[k * 2 + 1] += lazy[k] / 2; 
		lazy[k * 2 + 2] += lazy[k] / 2; 
	}
	lazy[k] = 0; 
}
void add(int a, int b, int k, int l, int r, int x){
	update(k); 	
	if(b <= l || r <= a) return; 
	if(a <= l && r <= b){
		lazy[k] += x * (r-l); 
		update(k); 
	}else{
		add(a, b, k * 2 + 1, l, (l+r)/2, x);
		add(a, b, k * 2 + 2, (l+r)/2, r, x);
		seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
	}
}
int query(int a, int b, int k, int l, int r){
	if(b <= l || r <= a) return 0; 
	update(k); 
	if(a <= l && r <= b) return seg[k];
	int vl = query(a, b, k * 2 + 1, l, (l+r)/2);
	int vr = query(a, b, k * 2 + 2, (l+r)/2, r);
	return vl + vr; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> M_;
	init(M_);
	pair<int, pair<int, int>> A[300010]; 
	for(int i = 0; i < N; i++){
		cin >> A[i].second.first >> A[i].second.second;
		A[i].first = A[i].second.second - A[i].second.first;
		A[i].second.first --; A[i].second.second --;
	}
	sort(A, A+N); 
	int id = 0;
	for(int q = 1; q <= M_; q++){
		while(A[id].first < q-1 && id < N){
			int l = A[id].second.first; 
			int r = A[id].second.second; 
			add(l, r+1, 0, 0, M, 1); 
			id++; 
		}
		int ans = N - id;
		for(int i = q - 1; i < M_; i += q){
			ans += query(i, i+1, 0, 0, M);
		}
		cout << ans << "\n"; 
	}
}

Measured memory_bytes: 9276
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A == B&&B==C){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
        
    }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int K = scan.nextInt();
		String S = scan.next();

		char c[] = S.toCharArray();
		c[K - 1] = Character.toLowerCase(c[K - 1]);
		System.out.println(new String(c));

	}
}

Measured memory_bytes: 21204
#include<cstdio>
inline int in();
inline void wr(int);
int main(int argc,char**argv){
	register int S=in(),W=in();
	if(W>=S)puts("unsafe");
	else puts("safe");
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


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

int main() {
  string S; cin >> S;
  string acgt = "ACGT";
  int cnt = 0;
  int maxcnt = 0;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 4; j++) {
      if (S.at(i) == acgt.at(j)) {
        cnt++;
        maxcnt = max(maxcnt, cnt);
        break;
      }
      if (j == 3) cnt = 0;
    }
  }
  cout << maxcnt << endl;
  return 0;
}

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

typedef pair<int, int> P;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)

const int N=4;

struct state{
  vector<int> board;
  int dist;
  int bi,bj;
  int miss_cnt;
  int mh_dist;
  int pre;
};

int h0(const state& s){
  return s.dist;
}
int h1(const state& s){
  return s.dist+s.miss_cnt;
}
int h2(const state& s){
  return s.dist+s.mh_dist;
}

int di[]={0,1,0,-1};
int dj[]={1,0,-1,0};

int ans[N][N]={
  {0,1,2,3},
  {4,5,6,7},
  {8,9,10,11},
  {12,13,14,-1},
};

P ans_ps[N*N];

bool ida_star(const state& crtstate,char x){
  if(h2(crtstate)>x)return false;

  if(crtstate.mh_dist==0)return true;

  rep(dir,4){
    if(dir==crtstate.pre)continue;
    int bi=crtstate.bi;
    int bj=crtstate.bj;
    int ni=bi+di[dir];
    int nj=bj+dj[dir];
    if(ni<0||ni>=N||nj<0||nj>=N)continue;
    state nxtstate=crtstate;

    int num=crtstate.board[ni*N+nj];
    int ai=ans_ps[num].fi;
    int aj=ans_ps[num].se;
    nxtstate.mh_dist-=abs(ai-ni)+abs(aj-nj);
    nxtstate.miss_cnt+=(abs(ai-ni)+abs(aj-nj)==0?1:0);
    nxtstate.mh_dist+=abs(ai-bi)+abs(aj-bj);
    nxtstate.miss_cnt-=(abs(ai-ni)+abs(aj-nj)==0?1:0);

    swap(nxtstate.board[bi*N+bj],nxtstate.board[ni*N+nj]);
    nxtstate.dist++;
    nxtstate.bi=ni; nxtstate.bj=nj;
    nxtstate.pre=(dir+2)%4;
    if(ida_star(nxtstate,x))return true;
  }
  return false;
}

int main(){

  clock_t start=clock();

  rep(i,N)rep(j,N){
    if(ans[i][j]==-1)continue;
    ans_ps[ans[i][j]].fi=i;
    ans_ps[ans[i][j]].se=j;
  }

  state inistate;
  inistate.board=vector<int>(N*N);
  inistate.dist=0;
  inistate.mh_dist=0;
  inistate.pre=-1;
  rep(i,N)rep(j,N){
    int input;
    cin>>input;
    input--;
    inistate.board[i*N+j]=input;
    if(input==-1){
      inistate.bi=i;
      inistate.bj=j;
    }else{
      int ai=ans_ps[input].fi;
      int aj=ans_ps[input].se;
      inistate.mh_dist+=abs(ai-i)+abs(aj-j);
    }
  }

  rep(x,45+1){
    if(ida_star(inistate,x)){
      cout<<x<<endl;
      break;
    }
  }

  clock_t end=clock();
  //cerr<<"duration = "<<(double)(end-start)/CLOCKS_PER_SEC<<" sec."<<endl;

  return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
int main(){
	int x,a=0;
	while(1){
		a=a+1;
		scanf("%d",&x);
		if(x==0){
			break;
		}
		else if(x!=0){
			printf("Case %d: %d\n",a,x);
		}
	}
	return 0;
}	

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main(){
    ll n, k ;
    cin >> n >> k ;
    if(n == 0){
        cout << n << endl ;
    }
    else {
        if(n % k == 0){
            cout << 0 << endl ;
        }
        else {
            ll r = n % k ;
            if(r > abs(r - k)){
                cout << abs(r - k) << endl ;
            }
            else {
                cout << r << endl ;
            }
        }
    }
}

Measured memory_bytes: 3628