akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#include <functional>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll

class Segtree { // inputは0-indexed
private:
	int N = -1;
	vector<int> data; //ゼロに近いほうが親
	function<int(int, int)> func;
	int e_id;
public:
	Segtree(int n_, function<int(int, int)> f, int e) {
		func = f; e_id = e;

		int N_ = 1;
		while (N_ < n_) N_ *= 2;
		N = N_;
		data.resize(2 * N - 1, e_id);
	}

	void update(int k, int a) {
		k += N - 1;
		data[k] = a; //１点更新 // add queryのときは data[k] += a;としなければならない
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = func(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	int query_sub(int a, int b, int k, int l, int r) {
		// k:現在見ているノードの位置  [l,r):dat[k]が表している区間
		if (r <= a || b <= l) { // 範囲外なら考えない
			return 0;
		}
		else if (a <= l && r <= b) { // 範囲内なので自身の値を返す
			return data[k];
		}
		else { // 一部区間が被る時
			int vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
			return func(vl, vr);
		}
	}
	int query(int a, int b) {
		if (b < a) swap(a, b);
		return query_sub(a, b + 1, 0, 0, N);
	}
};

signed main() {
	const int Mx = 3000010;
	int N, K; cin >> N >> K;
	auto fx = [](int x1, int x2) -> int { return max(x1, x2); };
	int e = 0;
	Segtree RMQ(Mx+1, fx, e);
	vector<int> vec(N);
	rep(i, N) {
		cin >> vec[i];
	}
	for (int i = 0; i < N; i++) {
		int left = max(ll(0), vec[i] - K);
		int right = min(Mx+1, vec[i] + K);
		int M = RMQ.query(left, right);
		RMQ.update(vec[i], M + 1);
	}
	cout << RMQ.query(0, Mx+1) << endl;
	sysp;
}

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


#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl


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

	string sh; cin >> sh;
	int length = sh.size();
	for (int i = 0; i < length; ++i)
	{
		if (i % 2 == 1)
		{
			if (sh[i] != 'L' && sh[i] != 'U' && sh[i] != 'D')
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else if (i % 2 == 0)
		{
			if (sh[i] != 'R' && sh[i] != 'U' && sh[i] != 'D')
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 1;
  
  int i = 0; // カウンタ変数
  while (i < N) {
   if (ans * 2 > ans + K) {
     break;
   }
   ans *= 2;
   i++;
  }
  for (int j = i; j < N; j++) {
   ans += K;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N = int(input())

sdict = {}

for i in range(N):
    inp = input()
    if inp in sdict:
        sdict[inp] += 1
    else:
        sdict[inp] = 1

# print(sdict)

maximum = sdict[max(sdict, key=sdict.get)]
# print(maximum)

rlist=[]

for k, v in sdict.items():
    if v == maximum:
        rlist.append(k)

rlist.sort()

for r in rlist:
    print(r)

Measured memory_bytes: 32096
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
ll dp[maxn],s[maxn];
ll val[maxn];
vector<int> adj[maxn],bdj[maxn];
int a[maxn],b[maxn],n,m;
pair<int,int> c[maxn];
int ufs[maxn];
int vis[maxn];
inline int find(int u){
	if (ufs[u]==u) return u;
	else return ufs[u]=find(ufs[u]);
}
inline bool cmp1(pair<int,int> a1,pair<int,int> b1){
	return a1.first<b1.first;
}
inline void dfs(int u,int fa){
	s[u]=b[u];
	for (int i=0;i<bdj[u].size();i++){
		int v=bdj[u][i];
		if (v==fa) continue;
		dfs(v,u);
		s[u]+=s[v];
	}
	if (bdj[u].size()==0){
		dp[u]=s[u]+val[u];
		return;
	}
	else dp[u]=1e16;
	for (int i=0;i<bdj[u].size();i++){
		int v=bdj[u][i];
		if (v==fa) continue;
		dp[u]=min(dp[u],max(dp[v],val[u])+s[u]-s[v]);
	}
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		c[i].first=max(0,a[i]-b[i]); 
		val[i]=c[i].first;
		c[i].second=i;
		ufs[i]=i;
	}
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	sort(c+1,c+n+1,cmp1);
	for (int i=1;i<=n;i++){
		int id=c[i].second;
		vis[id]=1;
		for (int j=0;j<adj[id].size();j++){
			int v=adj[id][j];
			if (vis[v]==0) continue;
			v=find(v);
			if (v==id) continue;
			bdj[id].push_back(v);
			ufs[v]=id;
		}
	}
	dfs(c[n].second,c[n].second);
	cout<<dp[c[n].second]<<endl;
}

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

int main(){

  int h, w, i, j;

  while(1) {
    cin >> h >> w;
    if(h ==0 && w ==0) break;

    for(i = 1; i <= h; i++) {
      for(j = 1; j <= w; j++) {
	if( (i+j) % 2 == 0) cout << "#";
	else cout << ".";
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}

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

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

  int num = stoi(a + b);

  bool tf = false;

  for (int i = 1; i < num/2; i++) {
    if (i* i == num) {
      tf = true;
    }
  }

  if (tf) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, h;
  cin >> n;
  int max_h = 0, ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> h;
    if (max_h <= h)
    {
      max_h = h;
      ans ++;
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]


N = int(input())
hoge = makelist(N+1, 3)
for i in range(1, N+1):
    a, b, c = map(int, input().split())
    hoge[i][0], hoge[i][1], hoge[i][2] = a, b, c


dp = makelist(N+1, 3)
dp[1][0] = hoge[1][0]
dp[1][1] = hoge[1][1]
dp[1][2] = hoge[1][2]

for i in range(2, N+1):
    for act in range(3):
        now = 0
        for sel in range(3):
            if act != sel:
                now = max(now, dp[i-1][sel])
        dp[i][act] = now + hoge[i][act]
ans = max(dp[N][0], max(dp[N][1], dp[N][2]))

print(ans)


Measured memory_bytes: 72924
#include <iostream>
#include <vector>
#include <utility>
#include <string>

#define MOD 1000000007LL

using namespace std;

typedef long long ll;

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

    ll dp[S.size()][13];

    for (int i=0; i<S.size(); ++i) {
        for (int j=0; j<13; ++j) {
            dp[i][j] = 0;
        }
    }

    if (S[0]=='?') {
        for (int i=0; i<10; ++i) {
            dp[0][i] = 1;
        }
    } else {
        int c = S[0] - '0';
        dp[0][c] = 1;
    }

    for (int i=1; i<S.size(); ++i) {
        if (S[i]=='?') {
            for (int j=0; j<10; ++j) {
                for (int ki=0; ki<13; ++ki) {
                    dp[i][(ki*10+j)%13] += dp[i-1][ki];
                }
            }
        } else {
            int c = S[i] - '0';
            for (int ki=0; ki<13; ++ki) {
                dp[i][(ki*10+c)%13] += dp[i-1][ki];
            }
        }
        for (int ki=0; ki<13; ++ki) {
            dp[i][ki] %= MOD;
        }
    }

    cout << dp[S.size()-1][5] << endl;



    return 0;

}

Measured memory_bytes: 10624
#include <iostream>

int main()
{
    int a,b,c,d,e,f;
    std::cin>>a>>b>>c>>d>>e>>f;
    if(a+b*5+c*10+d*50+e*100+f*500>=1000)
        std::cout<<1<<std::endl;
    else std::cout<<0<<std::endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#define MOD 1000000007
using namespace std;
const int MAXN = 100005;
int fac[MAXN*2],inv[MAXN*2],n,m,a,b;
typedef long long ll;
inline int ksm(int x,int k)
{
	int ret=1;
	while(k){
		if(k&1)ret=(ll)ret*x%MOD;
		x=(ll)x*x%MOD;
		k>>=1;
	}
	return ret;
}
inline void init()
{
	fac[0]=1;
	for(int i=1;i<=m+n;++i)
		fac[i]=(ll)fac[i-1]*i%MOD;
	inv[m+n]=ksm(fac[m+n],MOD-2);
	inv[0]=1;
	for(int i=m+n-1;i;--i)
		inv[i]=(ll)inv[i+1]*(i+1)%MOD;
}
inline int C(int n,int m)
{
	return (ll)fac[m]*inv[m-n]%MOD*inv[n]%MOD;
}
inline void add(int &x,int a)
{
	x+=a;
	if(x>=MOD)x-=MOD;
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	init();
	int ans=0;
	for(int i=1;i<=n-a;++i)
		add(ans,(ll)C(b-1,b-1+i-1)*C(n-i,n-i+m-b-1)%MOD);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

const int MOD = 1000000007;
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0;i<N;++i) cin >> A[i];

    long long num = 0;
    long long money = 1000;
    for(int i=0;i<N-1;++i){
        if(A[i] < A[i + 1]){
            num = money / A[i];
            money -= A[i] * num;
            money += A[i+1] * num;
            num = 0;
        }
    }
    cout << money << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<long long> counter(30, 0);
long long mini;
bool flag = 0;
int main() {
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++)
	{
		counter[str[i] - 'a']++;
		if (counter[str[i]- 'a'] >= 2) flag = 1;
	}
	
	if (flag) cout << "no";
	else cout << "yes";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int count(int);
int main(void){
   int n,x;
   while(1){
       cin >> n;
       if(n==0) break;

       x=count(n)/10;
       cout << x/365+1 << endl;
   }
}

int count(int n){
   if(n==1) return 1;
   else if(n==2) return 2;
   else if(n==3) return 4;
   else return count(n-1)+count(n-2)+count(n-3);
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int odd;
    if(n % 2 == 0) {
        odd = n / 2;
    } else {
        odd = n / 2 + 1;
    }
    cout << fixed << setprecision(10) << (double)odd / n << endl;
    return 0;
}

Measured memory_bytes: 3800
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = input()
    p = ''
    c = ''
    ans = 0
    for x in s:
        c += x
        if c == p:
            continue
        else:
            p = c
            c = ''
            ans += 1
    print(ans)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""


Measured memory_bytes: 9596
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input! {
        _n:usize,
        a:usize1,
        b:usize1,
        c:usize1,
        d:usize1,
        s:chars
    }

    let mut ok = true;
    if c > d {
        ok = false;
        for i in max(a, b)..d + 1 {
            if s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.' {
                ok = true;
            }
        }
    }

    for i in min(a, b)..max(c, d) {
        if s[i] == '#' && s[i + 1] == '#' {
            ok = false;
        }
    }

    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,k;
    cin >> h >> w >> k;
    string grid[h];
    int black = 0;
    for(int i = 0; i < h;i++){
        cin >> grid[i];
        for(int j = 0; j < w;j++){
            if(grid[i][j] == '#')
                black++;
        }
    }
    int ans = 0;
    for(int i = 0; i < (int)pow(2,h);i++){
        for(int j = 0;j < (int)pow(2,w);j++){
            int count = 0;
            vector<int> row,col;
            int temp = i;
            for(int r = 0;r < h;r++){
                if(temp&1){
                    row.push_back(r);
                }
                temp >>= 1;
            }
            temp = j;
            for(int c = 0; c < w;c++){
                if(temp&1){
                    col.push_back(c);
                }
                temp >>= 1;
            }
            for(int r = 0;r < row.size();r++){
                for(int c = 0;c < w;c++){
                    if(grid[row[r]][c] == '#')
                        count++;
                }
            }
            for(int c = 0;c < col.size();c++){
                for(int r = 0;r < h;r++){
                    if(grid[r][col[c]] == '#')
                        count++;
                }
            }
            for(int r = 0; r < (int)row.size();r++){
                for(int c = 0; c < (int)col.size();c++){
                    if(grid[row[r]][col[c]] == '#')
                        count--;
                }
            }
            if(black - count == k)
                ans++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4060
s = input()
l = len(s)
for i in range(l - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        break
    elif i == l - 2:
        continue
    elif s[i] == s[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, k, ans = 0;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int jy = -1;
		int keisan = 0;
		if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		}
//		System.out.println(x+" "+y);
		while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 26200
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

template <typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n) : n(n), dat(n + 1, 0) {}

    T sum(int idx) {
        T res(0);
        for (int i = idx; i > 0; i -= i & -i) res += dat[i];
        return res;
    }

    T sum(int l, int r) {
        return sum(r - 1) - sum(l - 1);
    }

    void add(int idx, T x) {
        if (idx == 0) return;
        for (int i = idx; i <= n; i += i & -i) dat[i] += x;
    }

    int lower_bound(T x) {
        if (x <= 0) return T(0);
        int res = 0, r = 1;
        while (r < n) r <<= 1;
        for (; r > 0; r >>= 1) {
            if (res + r <= n && dat[res + r] < x) {
                x -= dat[res + r];
                res += r;
            }
        }
        return res + 1;
    }

    T sum0(int idx) {
        return sum(idx + 1);
    }

    T sum0(int l, int r) {
        return sum(r) - sum(l);
    }

    void add0(int idx, T x) {
        add(idx + 1, x);
    }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> bit(n);
    int a;
    rep(i, n) {
        cin >> a;
        bit.add(i, a);
    }
    int Q, p, x, l, r;
    rep(i, q) {
        cin >> Q;
        if (Q) {
            cin >> l >> r;
            cout << bit.sum(l, r) << endl;
        } else {
            cin >> p >> x;
            bit.add(p, x);
        }
    }
    return 0;
}

Measured memory_bytes: 8268
X,Y,Z, K  = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

apb =  []

for a in A:
    for b in B:
        apb.append(a+b)
apb.sort(reverse=True)

apb = apb[:K]
ans = []

for k in apb:
    for c in (C):
        ans.append(k+c)
ans.sort(reverse=True)

for k in range(K):
    print(ans[k])

    


Measured memory_bytes: 148200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define M 1000000007

const int mod=M;
struct mint{
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-()const{
        return mint(-x);
    }
    mint &operator+=(const mint &a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;        
    }
    mint &operator-=(const mint &a){
        if((x+=mod-a.x)>=mod) x-=mod;
        return *this;        
    }
    mint &operator*=(const mint &a){
        (x*=a.x)%=mod;
        return *this;        
    }
    mint operator+(const mint &a)const{
        return mint(*this)+=a;        
    }
    mint operator-(const mint &a)const{
        return mint(*this)-=a;        
    }
    mint operator*(const mint &a)const{
        return mint(*this)*=a;        
    }
    mint pow(long long t)const{
        if(!t){
            return 1;
        }
        mint a=pow(t>>1);
        a*=a;
        if(t&1){
            a*=*this;
        }
        return a;
    }
    mint inv()const{
        return pow(mod-2);
    }
    mint &operator/=(const mint &a){
        return (*this)*=a.inv();
    }
    mint operator/(const mint &a)const{
        return mint(*this)/=a;
    }
};
istream &operator>>(istream &is,const mint &a){
    return is>>a.x;
}
ostream &operator<<(ostream &os,const mint &a){
    return os<<a.x;
}

struct combination{
    vector<mint> fact,ifact;
    combination(int n):fact(n+1),ifact(n+1){
        assert(n<mod);
        fact[0]=1;
        for(int i=1;i<=n;i++){
            fact[i]=fact[i-1]*i;
        }
        ifact[n]=fact[n].inv();
        for(int i=n;i>=1;i--){
            ifact[i-1]=ifact[i]*i;
        }
    }
    mint operator()(int n,int k){
        if(k<0||n<k){
            return 0;
        }
        return fact[n]*ifact[k]*ifact[n-k];
    }
}c(2000005);

int main(){
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll le=s.size();
    mint ans=0;
    for(ll i=0;i<=k;i++){
        ans+=c((int)(le+i-1),(int)i)*mint(25).pow(i)*mint(26).pow(k-i);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 36576
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

double dp[600];

double E(int n, vector<vector<int>> &G){
    for (int i = 0; i < n; ++i) {
        dp[i] = 0;
    }
    double ans = 0;
    dp[0] = 1;
    for (int i = 0; i < n-1; ++i) {
        if(G[i].empty() && dp[i]) return INF<int>;
        for (auto &&j : G[i]) {
            ans += dp[i]/G[i].size();
            dp[j] += dp[i]/G[i].size();
        }
    }
    return ans;
}



int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].emplace_back(t);
    }
    vector<double> dp2(n);
    dp2[n-1] = 1;
    for (int j = n - 1; j >= 0; --j) {
        for (auto &&i : G[j]) {
            dp2[j] += (dp2[i]+1)/G[j].size();
        }
    }
    for (int i = 0; i < n; ++i) {
        sort(G[i].begin(),G[i].end(), [&](int x, int y){return dp2[x] < dp2[y]; });
    }
    double ans = E(n, G);
    for (int i = 0; i < n; ++i) {
        if(!G[i].empty()){
            int x = G[i].back(); G[i].pop_back();
            ans = min(ans, E(n, G));
            G[i].emplace_back(x);
        }
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 1408
//
// スライド最小値
//
// cf.
//
//
// verified:
//   AOJ 0613 財宝 (JOI 2014 予選 F)
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0613
//

#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
using pll = pair<long long, long long>;


// slide min
template<class VAL, class TIME> struct SlideMin {
    const VAL INF = 1LL<<60; // to be set appropriately
    const TIME nul = -1; // to be set appropriately
        
    deque<pair<VAL, TIME> > deq;
    SlideMin()  { }

    // get minimum
    pair<VAL, TIME> get() {
        if (deq.empty()) return make_pair(INF, nul);
        return deq.front();
    }

    // push (v, t), "t is non-decreasing" is necessary
    void push(VAL v, TIME t) {
        while (!deq.empty() && deq.back().first >= v) deq.pop_back();
        deq.emplace_back(v, t);
    }

    // pop "< t", "t it non-decreasing" is necessary
    void pop(TIME t) {
        while (!deq.empty() && deq.front().second < t) deq.pop_front();
    }
};



vector<long long> X, Y;
void rec(int i, int last, long long x, long long y, vector<pll> &v) {
    if (i == last) {
        v.push_back(pll(x, y));
        return;
    }
    rec(i + 1, last, x, y, v);
    rec(i + 1, last, x + X[i], y - Y[i], v);
    rec(i + 1, last, x - X[i], y + Y[i], v);
}

int main() {
    int N; long long D; cin >> N >> D;
    X.resize(N); Y.resize(N);
    for (int i = 0; i < N; ++i) cin >> X[i] >> Y[i];
    vector<pll> L, R;
    rec(0, N/2, 0, 0, L);
    rec(N/2, N, 0, 0, R);
    sort(L.begin(), L.end(), greater<pll>());
    sort(R.begin(), R.end());

    long long res = 0;
    SlideMin<long long, long long> sm;
    int pos = 0;
    for (auto it : L) {
        // push
        while (pos < R.size() && R[pos].first <= -it.first + D) {
            sm.push(-R[pos].second, R[pos].first);
            ++pos;
        }
        
        // pop
        sm.pop(-it.first - D);

        // get
        long long minv = -sm.get().first;
        res = max(res, it.second + minv);
    }
    cout << res << endl;
}



Measured memory_bytes: 489260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder176
{
    class Program
    {
        static void Main(string[] args)
        {
            QC();
        }

        static void QA()
        {
            string line = Console.ReadLine();
            string[] splited = line.Split(' ');
            int N = int.Parse(splited[0]);
            int X = int.Parse(splited[1]);
            int T = int.Parse(splited[2]);

            Console.WriteLine(Math.Ceiling((double)N / X) * T);
        }

        static void QB()
        {
            string line = Console.ReadLine();
            long l = 0;
            foreach(char c in line)
            {
                l += short.Parse(c.ToString());
            }
            Console.WriteLine((l % 9 == 0) ? "Yes" : "No");
        }

        static void QC()
        {
            int N = int.Parse(Console.ReadLine());
            string[] Ai = Console.ReadLine().Split(' ');
            long sum = 0;
            int before = int.Parse(Ai[0]);
            int t = 0;

            for (int i = 1; i < N; i++)
            {
                t = int.Parse(Ai[i]);
                if (before <= t)
                {
                    // 前の人が自分の身長以下
                    // 台不要
                    before = t;
                }
                else
                {
                    // 前の人が自分の身長より大きい
                    // 前の人の身長の高さになるように台を設定
                    sum += before - t;
                }
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 43396
# -*- coding: utf-8 -*-

list = [int(input()) for i in range(5)]

mod = []

for a in list:
    v = 10-(a%10)
    if v == 10: mod.append(0)
    else:mod.append(10-(a%10))

mod = sorted(mod)

time = sum(list)

time += sum(mod[0:len(list)-1])

print(time)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll H, W;

    //input
    cin >> H >> W;

    char s[H][W];
    ll c[H][W];
    ll l, u;

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

    if(s[0][0] == '#'){
        c[0][0] = 1;
    }else{
        c[0][0] = 0;
    }
    for(ll k = 1; k < W; k++){
        if(s[0][k] == '#' && s[0][k - 1] == '.'){
            c[0][k] = c[0][k - 1] + 1;
        }else{
            c[0][k] = c[0][k - 1];
        }
    }
    for(ll k = 1; k < H; k++){
        if(s[k][0] == '#' && s[k - 1][0] == '.'){
            c[k][0] = c[k - 1][0] + 1;
        }else{
            c[k][0] = c[k - 1][0];
        }
    }
    for(ll i = 1; i < H; i++){
        for(ll j = 1; j < W; j++){
            l = c[i - 1][j];
            u = c[i][j - 1];
            if(s[i][j] == '#' && s[i - 1][j] == '.'){
                l++;
            }
            if(s[i][j] == '#' && s[i][j - 1] == '.'){
                u++;
            }
            if(l <= u){
                c[i][j] = l;
            }else{
                c[i][j] = u;
            }
        }
    }

    cout << c[H - 1][W - 1] << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define INF 1001001001
#define ll long long
#define rep(i,n)  for(i=0; i<n;  i++)
#define rep2(i,n) for(i=1; i<=n; i++)

int  get_min(int a, int b){ if(a<b) return a; else return b; }
int  get_max(int a, int b){ if(a>b) return a; else return b; }

int main(){
    char str[3] = {};
    scanf("%s",str);

    if(!strcmp(str, "AAA") || !strcmp(str, "BBB")){
        printf("No");
        return 0;
    }
    else    printf("Yes");
    return 0;
}

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

using namespace std;
typedef long long ll;

ll N, a[100000];

struct BIT {
	vector<ll> bit;
	int n;

	BIT(int a) {
		n = a;
		bit.resize(n + 1);
		for (int i = 0; i < n + 1; i++)bit[i] = 0;
	}

	ll sum(int i) {
		ll s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i, int x) {
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}

	ll sum(int l, int r) {
		//[l, r)
		return sum(r - 1) - sum(l - 1);
	}
};

bool f(ll value) {
	int geta = N + 1;
	BIT bit(N + geta + 20);
	ll rtn = 0;
	int Sum = 0;
	bit.add(geta, 1);
	for (int i = 0; i < N; i++) {
		Sum += (a[i] <= value ? 1 : -1);
		rtn += bit.sum(1, Sum + geta);
		bit.add(Sum + geta, 1);
	}
	if (rtn > N*(N + 1) / 4)return true;
	return false;

}

int main() {

	cin >> N;
	for (int i = 0; i < N; i++)cin >> a[i];
	ll up = 1 << 30, lw = 0;

	while (up - 1 != lw) {
		ll mid = (up + lw) / 2;
		if (f(mid))up = mid;
		else lw = mid;
	}
	cout << up << endl;

	return 0;
}

Measured memory_bytes: 2560
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():

    flag = False
    memo = []
    n = int(input())
    for i in range(1,10):

        if flag == True:
            break
        for j in range(1,10):

            memo.append(i*j)
            if n in memo:
                print("Yes")
                flag = True
                break




    if flag==False:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 13452
h,w = map(int,input().split())

grid = []

for i in range(h):
    grid.append(input())

dp = [[0 for i in range(w)] for i in range(h)]

dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if grid[i][j] != "#":
            if i-1 >= 0:
                dp[i][j] += dp[i-1][j]
            if j-1 >= 0:
                dp[i][j] += dp[i][j-1]
mod = 1000000007
print(dp[-1][-1] % mod)

Measured memory_bytes: 265612
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x * y / tmp;
}

int dp[85][85][2];

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> zero(64, 0), one(64, 0);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		for (int j = 60; j >= 0; j--)
		{
			if ((a[i] >> j) & 1LL) {
				one[j]++;
			}
			else
			{
				zero[j]++;
			}
		}
	}


	ll base = 1LL;
	ll ans = 0;
	for (int i = 0; i <= 60; i++)
	{
		ans += ((base * zero[i]) % MOD) * one[i];
		base *= 2LL;
		base %= MOD;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}



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

int main(){
    string s;
    cin>>s;
    int n=s.length();
    if(n<26){
        for(char c='a';c<='z';c++){
            if(find(s.begin(),s.end(),c)==s.end()){
                cout<<s+c<<endl;
                return 0;
            }
        }
    }else{
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<-1<<endl;
            return 0;
        }
        for(int i=0;i<25;i++){
            if(s[25-i]>s[24-i]){
                for(int j=0;j<24-i;j++) cout<<s[j];
                for(int j=25;j>=25-i;j--){
                    if(s[j]>s[24-i]){
                        cout<<s[j];
                        break;
                    }
                }
                break;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3632
import math
N = int(input())
X = [0., 0.]
Y = [100., 0.]

rad = math.pi / 2 * 2 /3

def rot(rad, pos):
    return [math.cos(rad)*pos[0] - math.sin(rad)*pos[1], math.sin(rad)*pos[0] + math.cos(rad)*pos[1]]


def coh(left, right, cnt):
    
    if cnt == 0:
        return
    else:
        s = [(right[0] - left[0]) / 3 + left[0], (right[1] - left[1]) / 3 + left[1]]
        t = [(right[0] - left[0]) * 2 / 3 + left[0], (right[1] - left[1]) * 2 / 3 + left[1]]
        ux, uy = rot(rad, [t[0] - s[0], t[1] - s[1]])
        u = [ux + s[0], uy + s[1]]

        coh(left, s, cnt-1)
        print(*s)
        coh(s, u, cnt-1)
        print(*u)
        coh(u, t, cnt-1)
        print(*t)
        coh(t, right, cnt-1)

print(*X)
coh(X, Y, N)
print(*Y)


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    bool ok = false;
    for (int i=0;i<=X;i++){
        int p = i*2 + (X-i)*4;
        if (p==Y) {
            ok = true;
            break;
        }
    }
    if (ok) cout << "Yes" << "\n";
    else cout << "No" << "\n";

}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int totalSum = 0;
		for (int i=1; i<=N; i++) {
			int sum = 0;

			int num = i;
			while (num != 0) {
				int hitoketame = num % 10;
				sum += hitoketame;
				num = num / 10;
			}

			if (sum >= A && sum <= B) {
				totalSum += i;
			}
		}

		System.out.println(totalSum);

	}

}


Measured memory_bytes: 22740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b,c;
  cin >> a>>b>>c;
  
  if(a%2==0 && a==b && b==c) {
  cout << -1 << endl;
  return 0;
  }
  
  int ans=0;
  rep(i,100){
    if(a%2==1 || b%2==1 || c%2==1) {
    cout << ans << endl; 
    return 0;
    }
    int s=a;
    int t=b;
    int u=c;
    a=(t+u)/2;
    b=(s+u)/2;
    c=(s+t)/2;
    ans++;
  }
  
}


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
}


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

using namespace std;

int main(void){
    
    int n;
    int a[] = {111,222,333,444,555,666,777,888,999};

    cin >> n;

    int min = 1000;
    int idx;
    for(int i = 0; i < 9; i++){
        if(min > a[i] - n && a[i] - n >= 0){
            min = a[i] - n;
            idx = i;
        }
    }

    cout << a[idx] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	cin>>b[i];
	int s=0; 
	for(int i=1;i<=n;i++)
	{
		if(a[i]>b[i])
		s+=a[i]-b[i];
	}
	cout<<s;
	return 0;
 } 

Measured memory_bytes: 3640
#include <iostream>
#include <string>

int main() {
    const std::string NO("No"), YES("Yes");
    int N,A,B;
    std::string s;
    std::cin >> N >> A >> B >> s;
    int pos = 0, cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'c') {
            pos -= 1;
            std::cout << NO << std::endl;
        }
        else if (s[i] == 'a') {
            if ((i + 1 + pos) <= (A+B)) std::cout << YES << std::endl;
            else {std::cout << NO << std::endl; --pos;}
        } else if (s[i] == 'b') {
            ++cnt;
            if ((i + 1 + pos) <= (A+B) && cnt <= B) std::cout << YES << std::endl;
            else {std::cout << NO << std::endl; --pos;}
        }
    }
    return 0;
}

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

bool allLettersSame(string s){
  for(int i=0; i<s.size(); i++){
    if(s[i] != s[0]) return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  
  long long k;
  cin >> k;
  
  if(allLettersSame(s)){
    cout << s.size()*k / 2 << endl;
    return 0;
  }
  
  int left=0, right=0;
  long long ans = 0;
  
  vector<int> counters;
  while(left < s.size()){
    while(right+1 < s.size() && s[left] == s[right+1])
      right++;
    
    int cnt = right - left + 1;
    counters.push_back(cnt);
    ans += cnt/2;
    left = right+1;
    right = left;
  }
  
  ans *= k;
  
  if(s[0] == s[s.size()-1] && 
    counters[0]%2==1 && 
    counters.back()%2==1 && 
    counters.size() != 1)
    ans += k-1;
  
  cout << ans << endl;
  return 0;
}

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

int main(){
    ll n,m;
    while(cin >> n >> m){
        ll lcm = 1;
        bool flag = true;
        vector<int>v;
        for( int i = 0; i < n; i++ ){
            ll a; cin >> a;
            a /= 2;
            v.push_back(a);
            lcm = ((lcm*a)/__gcd(lcm,a));
        }
        if(lcm > m){
            cout << "0\n";
            continue;
        }
        for( int i = 0; i < n; i++ ){
            if( (lcm/v[i])%2 == 0 ){
                cout << "0\n";
                break;
            }
            if( i == n-1 ){
                cout << 1 + (m-lcm)/(2*lcm) << "\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
  ll N,M;
  cin>>N>>M;
  vector< pair<ll, ll> > pairs(N);
  for (int i = 0; i < N; i++) cin>>pairs[i].first>>pairs[i].second;
  sort(pairs.begin(), pairs.end());
  ll sum;
  for (int i = 0; i < N; i++) {
    ll k,res;
    k = min(pairs[i].second, M);
    res = pairs[i].first*k;
    sum += res;
    M -= k;
    if (M <= 0) break;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;



int main(){
	int num[101],r,l,c;
	int kazu, target, t;
	int i;

	while (1){
		t = 0;
		cin >> kazu;

		if (kazu == 0){
			break;
		}

		for (i = 0; i < kazu; i++){
			cin >> num[i];
		}

		cin >> target;


		l = 0;
		r = (kazu - 1);
		t = 0;
		while (r>=l){
			c = (l + r) / 2;
			t++;
			if (num[c] == target){
				break;
			}else if (r<=l){
				break;
			}else if(num[c] < target){
				l = c + 1;
			}else{
				r = c - 1;
			}
			
		}


		cout << t << endl;
	}

}

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

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

    int answer = 0;

    if ( N <= 9 ){
        cout << N << endl;
    }
    else if (  10 <= N && N <= 99 ){
        cout << 9 << endl;
    }
    else if ( 100 <= N && N <= 999){
        answer = (N - 99) + 9;
        cout << answer << endl;
    }
    else if ( 1000 <= N && N <= 9999){
        cout << 909 << endl;
    }
    else if ( 10000 <= N && N <= 99999 ){
        answer = (N - 9999) + 909;
        cout << answer << endl;
    }
    else {
        cout << 90909 << endl;
    }
}

Measured memory_bytes: 256
def c_pushpush(N, A):
    from collections import deque
    ans = deque([])  # リストの先頭への挿入はO(要素数)なので
    n_parity = N & 1
    for i, a in enumerate(A, 1):
        if n_parity == i & 1:
            ans.appendleft(a)
        else:
            ans.append(a)
    return ' '.join(map(str, ans))

N = int(input())
A = [int(i) for i in input().split()]
print(c_pushpush(N, A))

Measured memory_bytes: 30020
import static java.lang.System.in;

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        while(true){
        int a = sc.nextInt();
        String k = sc.next();
        int b = sc.nextInt();

        String x = "+";
        String x2 = "-";
        String x3 = "*";
        String x4 = "/";
        String x5 = "?";

        if(k.equals(x)){
            System.out.println(a+b);
        }else if(k.equals(x2)){
            System.out.println(a-b);
        }else if(k.equals(x3)){
            System.out.println(a*b);
        }else if(k.equals(x4)){
            System.out.println(a/b);
        }else if(k.equals(x5)){
            break;
        }
    }
    }
}



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

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i]){
                prime[counter] = i;
                ++counter;
                if(counter >= prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
    constexpr int_fast64_t operator[](size_t i) const{
        return i < counter ? prime[i] : prime[counter - 1];
    }
};

constexpr Prime<8831, 1000> p = Prime<8831, 1000>();

constexpr int_fast64_t gcd(int_fast64_t a, int_fast64_t b){
    int_fast64_t t(0);
    while(b){
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

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

constexpr int_fast64_t lcm(int_fast64_t a, int_fast64_t b, int_fast64_t c, int_fast64_t d){
    return lcm(lcm(a, b), lcm(c, d));
}

struct Ans{
    int_fast64_t ans[502][502];
    constexpr size_t v(size_t i){
        return i & 1 ? i / 2 : 999 - i / 2;
    }
    constexpr Ans() : ans(){
        for(size_t i = 0; i < 501; ++i){
            ans[i][0] = 1;
            ans[501][i] = 1;
            ans[i + 1][501] = 1;
            ans[0][i + 1] = 1;
        }
        for(size_t i = 1; i <= 500; i += 2)
            for(size_t j = 1; j <= 500; j += 2){
                ans[i][j] = p[v((i + j - 2) / 2)] * p[v((1500 + i - j) / 2)];
                if(i < 500 && j < 500)ans[i + 1][j + 1] = p[v((i + j) / 2)] * p[v((1500 + i - j) / 2)];
            }
        for(size_t i = 1; i < 500; i += 2)
            for(size_t j = 1; j < 500; j += 2){
                ans[i + 1][j] = lcm(ans[i][j], ans[i + 2][j], ans[i + 1][j + 1], ans[i + 1][j - 1]) + 1;
                ans[i][j + 1] = lcm(ans[i][j], ans[i][j + 2], ans[i + 1][j + 1], ans[i - 1][j + 1]) + 1;
            }
    }
    constexpr int_fast64_t at(size_t i, size_t j)const{
        return ans[i + 1][j + 1];
    }
};

constexpr Ans a = Ans();
int_fast64_t N;

int main(){
    scanf("%lld", &N);
    for(size_t i = 0; i < N; ++i)
        for(size_t j = 0; j < N; ++j)printf("%lld%c", a.at(i, j), j == N - 1 ? '\n' : ' ');
}


Measured memory_bytes: 3072