akhauriyash/Code-Regression huggingface dataset:
//go:generate echo "https://atcoder.jp/contests/abc129/tasks/abc129_c"
package main

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

var scan = newScanner(os.Stdin)

func solve(n int, b map[int]bool) int {
	t := make([]mint, 100010, 100010)
	t[0] = 1
	for i := 0; i <= n; i++ {
		if !b[i+1] {
			t[i+1] = t[i+1].Add(t[i])
		}
		if !b[i+2] {
			t[i+2] = t[i+2].Add(t[i])
		}
	}
	return int(t[n])
}

func main1() {
	scan := newScanner(os.Stdin)
	n, m := scan.Int(), scan.Int()
	b := map[int]bool{}
	for i := 0; i < m; i++ {
		b[scan.Int()] = true
	}
	fmt.Println(solve(n, b))
}

func solve2(N int, as map[int]bool) int {
	t := make([]mint, N+1, N+1)
	t[0] = newMint(1)
	for i := 1; i < N+1; i++ {
		if 1 < i && !as[i-2] {
			t[i] = t[i].Add(t[i-2])
		}
		if !as[i-1] {
			t[i] = t[i].Add(t[i-1])
		}
	}
	return int(t[N])
}

func main() {
	N, M := scan.Int(), scan.Int()
	as := map[int]bool{}
	for i := 0; i < M; i++ {
		as[scan.Int()] = true
	}
	fmt.Println(solve2(N, as))
}

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

const (
	mod = 1000000007
)

type mint int

func newMint(v int) mint {
	return mint((v%mod + mod) % mod)
}

func (x mint) Add(y mint) mint {
	v := x + y
	if v >= mod {
		return v - mod
	}
	return v
}

func (x mint) Sub(y mint) mint {
	v := x + mod - y
	if v >= mod {
		return v - mod
	}
	return v
}

func (x mint) Mul(y mint) mint {
	return (x * y) % mod
}

func (x mint) pow(n int) mint {
	if n == 0 {
		return mint(1)
	}
	a := x.pow(n >> 1)
	a = a.Mul(a)
	if n&1 != 0 {
		a = a.Mul(x)
	}
	return a
}

func (x mint) Inverse() mint {
	return x.pow(mod - 2)
}

func (x mint) Div(y mint) mint {
	return x * y.Inverse()
}

func (x mint) Neg() mint {
	return newMint(int(-x))
}

type factorial struct {
	fact        []mint
	factInverse []mint
}

func newFactorial(n int) *factorial {
	f := new(factorial)
	f.init(n)
	return f
}

func (f *factorial) init(n int) {
	fact := make([]mint, n+1, n+1)
	fact[0] = newMint(1)
	for i := 1; i <= n; i++ {
		fact[i] = fact[i-1].Mul(newMint(i))
	}

	inv := make([]mint, n+1, n+1)
	inv[n] = fact[n].Inverse()
	for i := n; i >= 1; i-- {
		inv[i-1] = inv[i].Mul(newMint(i))
	}

	f.fact = fact
	f.factInverse = inv
}

func (f *factorial) Get(n int) mint {
	return f.fact[n]
}

func (f *factorial) GetInverse(n int) mint {
	return f.factInverse[n]
}

func (f *factorial) Permutation(n, k int) mint {
	if k < 0 || n < k {
		return 0
	}
	return f.fact[n].Mul(f.factInverse[n-k])
}

func (f *factorial) Combination(n, k int) mint {
	if k < 0 || n < k {
		return 0
	}
	return f.fact[n].Mul(f.factInverse[k]).Mul(f.factInverse[n-k])
}


Measured memory_bytes: 6076
n,m = map(int, input().split())
a_b = [list(map(int, input().split())) for i in range(n)]

a_b.sort()
sum_,all_ = m,0
for j in range(n):
  if sum_>=a_b[j][1]:
    sum_-=a_b[j][1]
    all_+=a_b[j][1]*a_b[j][0]
  elif sum_<a_b[j][1]:
    all_+=sum_*a_b[j][0]
    sum_-=sum_
print(all_)
      
    

Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5;
const int maxm = 5e5 + 5;
const ll inf = 2147483647;
int n, m, k;
int a[101], b[101];
int main(){
    int n;
    cin>>n;
    for(int i = 0; i < n; i++)cin>>a[i];
    for(int i = 1; i < n; i++){
        b[i] = a[i] - a[i - 1];
    }
    ll sum = 1000, k;
    for(int i = 1; i < n; i++){
        if(b[i] <= 0)continue;
        k = sum / a[i - 1];
        sum += (k * b[i]);
    }
    cout<<sum;
    return 0;
}


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

int main(){
  int n,T;
  cin >>n >>T;
  int curMin = 1e8;
  rep(i,n){
    int c,t;
    cin >>c >>t;
    if(t<=T) {
      curMin = min(curMin, c);
    }
  }
  if(curMin == 1e8) cout << "TLE" << endl;
  else cout << curMin << endl;
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll dp[50];

void solve() {
    int n; cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    rep(i, n){
        dp[i+2] = dp[i+1] + dp[i];
    }

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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7304
#include <bits/stdc++.h>
#define FOR(input) for (int a = 0; a < input; a++)
using namespace std;

long long  x,m,k,y,z;
string s1;
map<string,bool> mp;

int main() {
	cin >> x;
	FOR(x) {
		cin >> s1;
		if (mp[s1] == 0) k++;
		mp[s1] = 1;
	}
	cout << k << "\n";
	return 0;
}

Measured memory_bytes: 19172
import sys

x, y, a, b, c = map(int, sys.stdin.readline().split())
*p, = map(int, sys.stdin.readline().split())
*q, = map(int, sys.stdin.readline().split())
*r, = map(int, sys.stdin.readline().split())

def main():
    cnt = [0] * 3
    cand = []
    for i in p:
        cand.append((i, 0))
    for i in q:
        cand.append((i, 1))
    for i in r:
        cand.append((i, 2))
    cand.sort()

    tot = 0
    res = 0
    for _ in range(a+b+c):
        d, k = cand.pop()
        if k == 0:
            if cnt[0] == x:
                continue
            cnt[0] += 1
            res += d
            tot += 1
        elif k == 1:
            if cnt[1] == y:
                continue
            cnt[1] += 1
            res += d
            tot += 1
        elif k == 2:
            cnt[2] += 1
            res += d
            tot += 1
        if tot == x + y:
            break

    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 39440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+5;

int main(void) {
	int x, n; cin >> x >> n;
	int a[105];
	memset(a, 0, sizeof(a));
 
	for (int i = 0; i < n; ++i) {
		int in; cin >> in;
		++a[in];
	}
 
	if (!n) {
		cout << x << endl;
		return 0;
	}
 
	int cnt = 101, ans = 0;
	for (int i = 0; i < 105; ++i) {
		if (!a[i]) {
			if (abs(x - i) < cnt) {
				cnt = abs(x - i);
				ans = i;
			}
		}
	}
 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int l,r,d; cin >> l >> r >> d;
    cout<<r/d-(l-1)/d<<endl;
}

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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    
    ll n;
    cin >> n;
    set<string> SET;
    for(ll i=0;i<n;i++){
        string s;
        cin >> s;
        SET.I(s);
    }

    cout << SET.size();
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 19272
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil;

Node* listSearh(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if (cur == nil) break;
        if( isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t); 
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearh(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    char com[20];
    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
        }
        else if (com[0] == 'd'){
            if (strlen(com) > 6){
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            }
            else
            {
                deleteKey(key);
            }
            
        }
    }
    printList();
    return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 310, M = 1010;

int n, m, k, d;
int g[N][N];
PII p[N * N];

int main()
{
	scanf("%d%d%d", &n, &m, &d);
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
		{
			scanf("%d", &g[i][j]);
			p[g[i][j]] = {i, j};
		}
	// p[0] = p[d];
		
	vector<vector<LL>> s(d + 10);
	for (int i = 0; i < d; i ++ )
	{
		s[i].resize((n * m + d - 1) / d + 10);
		s[i][0] = 0;
		for (int j = 0; i + (j + 1) * d <= n * m; j ++ )
		{
			int l = j * d + i, r = (j + 1) * d + i;
			// if (i == 2) cout << l << ' ' << r << endl;
			LL x1 = p[l].F, y1 = p[l].S;
			LL x2 = p[r].F, y2 = p[r].S;
			LL sum = abs(x1 - x2) + abs(y1 - y2);
			
			s[i][j + 1] = s[i][j] + sum;
		}
	}
		
	scanf("%d", &k);
	while (k -- )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		
		if (l == r) puts("0");
		else
		{
			int t = l % d;
			printf("%lld\n", s[t][r / d] - s[t][l / d]);
		}
	}
	return 0;
}


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

#define MAX 1001

int LCSLength(char *, char *);

int main() {
  int q, i;
  char X[MAX], Y[MAX];

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%s%s", X, Y);
    printf("%d\n", LCSLength(X,Y));
  }
  return 0;
}

int LCSLength(char *X, char *Y) {
  int c[MAX][MAX], m, n, i, j;

  m = strlen(X);
  n = strlen(Y);

  for (i = 1; i <= m; i++) {
    c[i][0] = 0;
  }
  for (j = 0; j <= n; j++) {
    c[0][j] = 0;
  }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (X[i - 1] == Y[j - 1]) {
	c[i][j] = c[i - 1][j - 1] +1;
      } else if (c[i - 1][j] >= c[i][j - 1]) {
	c[i][j] = c[i - 1][j];
      } else {
	c[i][j] = c[i][j - 1];
      }
    }
  }
  return c[m][n];
}



Measured memory_bytes: 5636
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

# cythonライブラリよみこみ
from libcpp cimport bool
from libcpp.vector cimport vector as Vec
from libcpp.deque cimport deque as Deque
from libcpp.unordered_map cimport unordered_map as Map
from libcpp.unordered_set cimport unordered_set as Set
from libcpp.pair cimport pair as Pair
from libcpp.string cimport string as Str
from libcpp.queue cimport priority_queue as PriorityQueue
cimport libc.math as cmath

# define 
ctypedef long long LL
ctypedef long double LD
ctypedef Vec[LL] VLL #vector[long long]
ctypedef Vec[LD] VLD #vector[long double]
ctypedef LL[:] Arr
ctypedef LL[:,:] Arr2d
ctypedef LL[:,:,:] Arr3d
ctypedef LL[:,:,:,:] Arr4d #ちなみに7次元までサポートしてる


# cythonの関数定義
# TODO LL以外の型にも対応させた
cdef chmin(LL *x, LL y):
    #使用例 chmin(&dp[i + 1,jv], dp[i,j] +W[i])
    if y<x[0]:
        x[0]=y

cdef chmax(LL *x,LL y):
    #使用例 chmax(&dp[i + 1,jv], dp[i,j] +W[i])
    if x[0]<y:
        x[0]=y


cdef extern int __builtin_popcount(unsigned int) nogil #bitの数

import numpy as np
from functools import partial
array=partial(np.array, dtype=np.int64)
zeros=partial(np.zeros, dtype=np.int64)
full=partial(np.full, dtype=np.int64)

# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち

def exit(*argv,**kwarg):
    print(*argv,**kwarg)
    sys.exit()


cdef LL a_int(): return int(readline())

def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)
def doubles(): return np.fromstring(readline(), sep=' ', dtype=np.longdouble)

def py_ints() : list(map(int, readline().split()))

def read_matrix(LL H,LL W):
    #return np.ndarray shape=(H,W) matrix
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)


cdef LL MOD = 10**9 + 7
cdef LL INF= 9_223_372_036_854_775_807 #LLのmax

# python import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from bisect import bisect_left, bisect_right #, insort_left, insort_right
from functools import reduce
from math import gcd

cdef LL a,b
a,b=ints()
print('Odd' if (a*b)&1 else 'Even')
'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 26844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,S;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(a.at(i)<a.at(j)){
        S=a.at(i);
        a.at(i)=a.at(j);
        a.at(j)=S;
      }
    }
  }
  S=1;
  for(int i=1;i<N;i++)if(a.at(i-1)!=a.at(i))S++;
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 100005;
ll val[1<<16];
ll dp[1<<16];
ll solve(int mask) {
	if (~dp[mask]) {
		return dp[mask];
	}
	ll mx = -1e18;
	int low = mask & (mask);
	for (int s = mask ; s; s = (s - 1) & mask) {
		if (!(s & low))continue;
		mx = max(mx, solve(mask ^ s) + val[s]);
	}
	return dp[mask] = mx;
}
void go() {
	int n;
	cin >> n;
	f(n) {
		fr(j,0,n) {
			int x;
			cin >> x;
			if (i <= j)continue;
			for (int k = 0 ; k < (1<<n) ; k++) {
				if ((k & (1<< i)) && (k & (1<<j))) {
					val[k] += x;
				}
			}
		}
	}
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	cout << solve((1 << n) - 1) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

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

using namespace std;

#define RMAX 10
#define CMAX 10000

int main(){

	int R,C;
	int osenbei[RMAX][CMAX],tmposen[RMAX][CMAX];
	int ans;
	int cnt;
	int sum;

	while(1){
		cin>>R>>C;
		if(R==0&&C==0) break;
		ans=-1;
		for(int i=0;i<R;i++){
			for(int j=0;j<C;j++){
				cin>>osenbei[i][j];
			}
		}
		for(int i=0;i<(1<<R);i++){
			for(int j=0;j<R;j++){
				for(int k=0;k<C;k++){
					tmposen[j][k]=osenbei[j][k];
				}
			}
			for(int j=0;j<R;j++){
				if(((i>>j)&1)==1){
					for(int k=0;k<C;k++){
						if(tmposen[j][k]==1) tmposen[j][k]=0;
						else tmposen[j][k]=1;
					}
				}
			}
			sum=0;
			for(int j=0;j<C;j++){
				cnt=0;
				for(int k=0;k<R;k++){
					if(tmposen[k][j]==0)  cnt++;
				}
				sum+=max(cnt,R-cnt);
			}
			if(ans<sum) ans=sum;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1940
n = int(input())
robots = []
for _ in range(n):
    xi, li = map(int, input().split())
    robots.append((xi - li, xi + li))
robots.sort(key=lambda x: x[1])
ans = 0
pre_r = -float('inf')
for l, r in robots:
    if pre_r <= l:
        ans += 1
        pre_r = r
print(ans)


Measured memory_bytes: 18260
#include<iostream>
using namespace std;
int main() {
	int i, j, H, W;
	while (1) {
		cin >> H >> W;

		if (H == 0 && W == 0) { break; }

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {

				if (i%2==0) {
					if(j%2==1){
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
				else {
					if (j % 2 == 1) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

#define ll long long int
#define pii pair<int, int>
#define PII pair<ll, ll>
#define llu long long unsigned
#define ld long double

const ll MAX = 1e18 + 100;
const ll Max = 1e9 + 500;

const int sz=2e5+100;
int sum[22];
int ara[sz];
void ADD(int id,int val)
{
   for(int i=0;i<20;i++){
      if((ara[id] & (1<<i)) != 0) sum[i]+=val;
   }

}

bool check()
{
    for(int i=0;i<20;i++){
       if(sum[i]>1) return false;
    }
    return true;
}


int main()
{
   int t, i, j, k, p, q, a, b, c, mx,n,x;
   
   cin>>n;
   for(i=0;i<n;i++) cin>>ara[i];

   ll ans=0;
   i=0, j=0;

   while(i<n){
       
       ADD(i,+1);
       while(j<i && check()==false){
          ADD(j,-1);
          ++j;
       }

       ll p=(i-j+1);
       ans+=p;
       ++i;
   }

   cout<<ans<<'\n';
   
}

Measured memory_bytes: 4420
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String n = sc.next();

        long sum = 0;

        for (int i = 0; i < n.length(); i++) {
            sum += Integer.parseInt(String.valueOf(n.charAt(i)));
        }

        System.out.println(sum % 9 == 0 ? "Yes" : "No");

    }
}


Measured memory_bytes: 50232
from collections import deque
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
d = [[-1] * N for _ in range(2)]
for i in range(2):
    d[i][i * (N - 1)] = 0
    q = deque([i * (N - 1)])
    while len(q) > 0:
        u = q.popleft()
        for v in edge[u]:
            if d[i][v] > -1:
                continue
            d[i][v] = d[i][u] + 1
            q.append(v)
S = 0
F = 0
for i in range(N):
    if d[0][i] > d[1][i]:
        S += 1
    else:
        F += 1
if F > S:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 63520
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$n = $sc->nextInt();
$array = [];
$isZero = false;
$isOverflow = false;
$answer = 1;

for($i=0;$i<$n;$i++){
    $array[$i] = $sc->nextInt();
    if($array[$i] == 0){
        $isZero = true;
        break;
    }
}

for($i=0;$i<$n;$i++){
    $answer = $answer * $array[$i];
    if($answer>pow(10,18)){
        $isOverflow = true;
        break;
    }
}

if($isZero){
    echo "0".PHP_EOL;
}
  else if($isOverflow){
    echo "-1".PHP_EOL;
}  else {
    echo $answer.PHP_EOL;
}


Measured memory_bytes: 30476
long long int Xor(long long int a, long long int b) {
 return a * (a & 1) ^ b * !(b & 1) ^ !!(((a ^ b) + 1) & 2);
}
int main()
{
    long long int a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",Xor(a,b));
}

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

int main(){
    long long N, M;
    cin >> N >> M;
    long long k[M+1];
    vector<long long> s_sub;
    long long i, j;
    for(j = 0; j <= N; j++){
        s_sub.push_back(-1);
    }
    vector<vector <long long>> s;
    for(i = 0; i <= M; i++){
        s.push_back(s_sub);
    }
    for(i = 1; i <= M; i++){
        cin >> k[i];
        for(j = 1; j <= k[i]; j++){
            cin >> s[i][j];
        }
    }
    long long p[M+1];
    for(i = 1; i <= M; i++){
        cin >> p[i];
    }
    
    long long zentori = 1, bit;
    for(j = 1; j <= N; j++){
        zentori *= 2;
    }
    long long onoff[N+1];
    long long onoffsum;
    bool countif;
    long long counta = 0;
    for(bit = 0; bit < zentori; bit++){
        countif = 1;
        for(j = 1; j <= N; j++){
            if((bit >> (j-1)) & 1){
                onoff[j] = 1;
            }else{
                onoff[j] = 0;
            }
        }
        for(i = 1; i <= M; i++){
            onoffsum = 0;
            for(j = 1; j <= k[i]; j++){
                onoffsum += onoff[s[i][j]];
            }
            if(onoffsum % 2 != p[i]){
                countif = 0;
                break;
            }
        }
        if(countif){
            counta++;
        }
    }
    cout << counta << endl;
    system("pause");
    return 0;
}

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

int A[100005];
void partition(int p, int r)
{
    int x = A[r];
    int i = p-1;
    for(int j=p; j<r; j++)
    {
        if(A[j] <= x)
        {
            i++;
            swap(A[i],A[j]);

        }
    }
    swap(A[i+1],A[r]);
    for(int k=0; k<r; k++)
    {
        if(k == i+1)
        {
            cout << "[" << A[k] << "]" << " ";
        }
        else
            cout << A[k] << " ";
    }
    cout << A[r] << endl;
}
int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> A[i];
    partition(0, n-1);

    return 0;
}

Measured memory_bytes: 3480
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll X, A, B;
    cin>>X>>A>>B;
    if(B-A<=0) cout<<"delicious"<<endl;
    else if(B-A<=X) cout<<"safe"<<endl;
    else cout<<"dangerous"<<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++)
typedef long long ll;

int main() {
    int n, W;
    cin >> n >> W;
    vector<pair<int, int>> p;
    map<int, int> id;
    vector<ll> ww(4);
    int cnt = 0;
    rep(i, n) {
        int w, v;
        cin >> w >> v;
        p.emplace_back(make_pair(w, v));
        if (!id.count(w)) {
            id[w] = cnt;
            ww[cnt] = w;
            cnt++;
        }
    }
    sort(p.rbegin(), p.rend());
    int m = id.size();
    vector<vector<ll>> v(m), sum(m);
    for (int i = 0; i < n; i++) {
        int j = id[p[i].first];
        v[j].emplace_back(p[i].second);
    }

    for (int i = 0; i < m; i++) {
        sum[i].resize((int)v[i].size() + 1, 0);
        for (int j = 0; j < v[i].size(); j++) sum[i][j + 1] = sum[i][j] + v[i][j];
    }
    ll res = 0;
    auto dfs = [&](auto&& f, ll value = 0, ll weight = 0, int i = 0) -> void {
        if (weight > W) return;
        res = max(res, value);
        if (i >= m) return;
        for (int j = 0; j < sum[i].size(); j++) {
            f(f, value + sum[i][j], weight + ww[i] * j, i + 1);
        }
    };
    dfs(dfs);
    cout << res << endl;
    return 0;
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  REP(i,n) {
    if (c*i - d*(n-1-i) <= a-b && a-b <= d*i - c*(n-1-i)) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc075/tasks/abc075_b
hw_list = list(map(int, input().split()))
h_max = hw_list[0]
w_max = hw_list[1]

s_list = []

for i in range(h_max):
    work_list = input()
    s_list.append(work_list)
answer_list = []

for h in range(h_max):
    work_list = s_list[h]
    work_answer = []
    for w, target in enumerate(work_list):
        if target == '.':
            tonari_list = [(w-1, h-1), (w, h-1), (w+1, h-1),
                           (w-1, h), (w+1, h),
                           (w-1, h+1), (w, h+1), (w+1, h+1)]
            count = 0
            for x, y in tonari_list:
                if 0 <= x < w_max and 0 <= y < h_max:
                    if s_list[y][x] == '#':
                        count += 1
                else:
                    continue
            work_answer.append(str(count))
        else:
            work_answer.append('#')
    answer_list.append(work_answer)

for a_list in answer_list:
    print(''.join(a_list))


Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;

int a,b,c,d;

char p1='+';
char p2='-';

string t="=7";

int main(){
	string s;
	cin>>s;
	a=(int)(s[0]-'0');
	b=(int)(s[1]-'0');
	c=(int)(s[2]-'0');
	d=(int)(s[3]-'0');
	if(a+b+c+d==7){ 
		cout<<a<<p1<<b<<p1<<c<<p1<<d<<t<<endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout<<a<<p1<<b<<p1<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout<<a<<p1<<b<<p2<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout<<a<<p1<<b<<p2<<c<<p1<<d<<t<<endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout<<a<<p2<<b<<p1<<c<<p1<<d<<t<<endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout<<a<<p2<<b<<p1<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout<<a<<p2<<b<<p2<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout<<a<<p2<<b<<p2<<c<<p1<<d<<t<<endl;
		return 0;
	}
	return 0;
}

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


int main(){
  int k,x,length,min,i;
  cin >> k >> x;

  min=x-(k-1);

  length=k+(k-1);

  for(i=0;i<length;i++){
    cout << min << " ";
    min = min+1;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<double> vecd;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }
#define DUMP(a) \
    do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) \
    do { std::cout << #a " = " << (a) << std::endl; } while(false)

int used[MAXN];
veci G[MAXN];
int N, M;

void fill(int u) {
    if(used[u]) return ;
    used[u] = 1;
    FORIT(it, G[u]) {
        fill(*it);
    }
}

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

    cin >> N >> M;
    FORO(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        G[x].EB(y);
        G[y].EB(x);
    }

    int ans = 0;
    FORO(i, N) {
        if(used[i]) continue;
        fill(i);
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13300
import math

n,m = map(int,input().split())

p = []

for i in range(1,int(math.sqrt(m))+1):
    if (m % i) == 0:
        p += [i,m//i]

ret = 1
for i in p:
    if m // i >= n:
        ret = max(ret,i)
#print(p)
print(ret)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d=0;
  string s;
  cin >>a>>b>>c>>d;
  if(abs(a-c)<=d) cout <<"Yes\n";
  else{
    if(abs(a-b)<=d&&abs(b-c)<=d) cout <<"Yes\n";
    else cout <<"No\n";
  }
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n;  cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int f=0,b=n-1;
	ll frnt=a[0], bck=a[n-1];
	while(abs(f-b)>1){
		if(frnt > bck) bck+= a[--b];
		else frnt+=a[++f];
	}
	cout<<abs(frnt-bck)<<'\n';
	return 0;
}

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

int main(){
    int K, N;
    cin >> K >> N;
    vi A(N);
    rep(i, N) cin >> A[i];

    int longest = 0;
    int tmp = A[0];
    rep(i, N){
        longest = max(longest, A[i] - tmp);
        tmp = A[i];
    }

    longest = max(longest, K - A[N-1] + A[0]);

    cout << K - longest << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
ll ans[N];

int main(){
	boost;
	int n,w;
	cin>>n>>w;
	ll arr[n][2];
	
	ll sum = 0;
	for(int i = 0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
		sum = sum + arr[i][1];
	}
	
	ll an = 0;
	for(int i = n-1;i>=0;i--){
		for(int j = sum;j>=0;j--){
			if(arr[i][1] == j){
				if(ans[j]==0)
					ans[j] = arr[i][0];
				else
					ans[j] = min(arr[i][0],ans[j]);
			}
			
			if(i<n-1){
				int k = j - arr[i][1];
				if(k>=0&&ans[k]>0){
					if(ans[j]==0)
						ans[j] = arr[i][0] + ans[k];
					else
						ans[j] = min(arr[i][0] + ans[k], ans[j]);
				}
			}
			
			if(ans[j]>0&&ans[j]<=w){
				an = max(an,(ll)j);
			}
			
			//cout<<ans[j]<<" ";
		}
		//cout<<endl;
	}
	
	cout<<an;
	return 0;
}

//Total solved problems:- 13



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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  vector<ll> H(N);
  REP(i, N) { cin >> H.at(i); }
  for (int i = N - 1; i > 0; --i) {
    if (H.at(i) < H.at(i - 1)) {
      if (H.at(i) == H.at(i - 1) - 1) {
        --H.at(i - 1);
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const ll inf = 1LL << 60;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, L, Q;
    cin >> N;
    vector<ll> x(N+1);
    x[N] = inf;
    Rep (i, N) cin >> x[i];
    cin >> L >> Q;
    vector<ll> a(Q), b(Q);
    Rep (i, Q) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    vector<vector<ll>> dpi(20, vector<ll>(N, 0)), dpd(20, vector<ll>(N, 0));
    Rep (i, N) {
        dpi[0][i] = upper_bound(x.begin(), x.end(), x[i]+L) - x.begin() - 1;
    }


    Rep (i, 19) {
        Rep (j, N) {
            dpi[i+1][j] = dpi[i][dpi[i][j]];
        }
    }

    // Rep (i, 4) {
    //     Rep (j, N) {
    //         cout << dpi[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    
    Rep (i, Q) {
        if (a[i] > b[i]) swap(a[i], b[i]);
        ll day = 0;
        for (ll j = 19; j >= 0; j--) {
            if (dpi[j][a[i]] < b[i]) {
                a[i] = dpi[j][a[i]];
                day += 1 << j;
            }
        }

        cout << day + 1 << "\n";
    }
}


Measured memory_bytes: 35312
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		final int MOD = 1000000007;

		//入力
		int n = sc.nextInt();
		long t = sc.nextInt();
		long[] times = new long[n];
		for(int i = 0; i < n; i++){
			times[i] = sc.nextLong();
		}
		sc.close();

		//処理
		long ans = (long)n * t;
		long last = 0;
		for(int i = 0; i < n; i++){
			if(times[i] < last){
				ans -= last - times[i];
			}
			last = times[i] + t;
		}

		//出力	
		out.println(ans);
		out.flush();
	}

	static class Pair{
		int a,b;
		public Pair(int a, int b){
			this.a = a;
			this.b = b;
		}
	}
}

Measured memory_bytes: 63328
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	v = a[i]
	j = i-1
	while j >= 0 and a[j] > v:
		a[j+1] = a[j]
		j -= 1
	a[j+1] = v
	print(*a)


Measured memory_bytes: 5976
#include<stdio.h>

int main(void) {
  
  int A, B, K;
  scanf("%d %d %d", &A, &B, &K);
  
  
  if (B-(K-1) > A+(K-1)) {
    for (int i = 0; i < K; i++) {
      printf("%d\n", A+i);
    }
    for (int i = 0; i < K; i++) {
      printf("%d\n", B-(K-1)+i);
    }
  } else {
    int i = A;
    while (i <= B) {
      printf("%d\n", i);
      i++;
    }
  }
  
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int two = 0, four = 0;
	rep(i,n){
		int a;
		cin >> a;
		if(a%4 == 0) ++four;
		else if(a%2 == 0) ++two;
	}
	if(2 * four + 1 >= n || 2 * four + two >= n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll x, y;

		ll X;
		cin >> X;
		cin >> n;

		ll p[n];

		for (i = 0; i < n; i++) cin >> p[i];

		ll ans = 1e10;
		ll dis = 1e10;
		for (i = - 200; i <= 200; i++) {
			ll fl = 0;
			for (j = 0; j < n; j++) {
				if (i == p[j]) {
					fl = 1;
					break;
				}
			}

			if (fl) continue;

			if (abs(X - i) < dis) {
				dis = abs(X - i);
				ans = i;
			}



		}

		cout << ans << endl;

	}
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    string s;
    cin >> s;
    int n = s.size(),m = 2019,t = 1;
    vector<int> cnt(m,0);
    int sum = 0;
    ll ans = 0;
    cnt[0]++;
    for (int i = n-1;i >= 0;--i) {
        (t *= 10) %= m; 
        sum = (sum+(s[i]-'0')*t)%m;
        ans += cnt[sum];
        cnt[sum]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)

// constant
// const ll MOD = 1e9 + 7;
// const ll INF = 1e12;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

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


int main()
{
    int N, cpN, dsum = 0;
    cin >> N;
    cpN = N;
    while (cpN > 0) {
        dsum += cpN % 10;
        cpN /= 10;
    }
    cout << (N % dsum == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll N, A, B; cin >> N >> A >> B;
  cout << (N/(A+B))*A + min(N%(A+B),A) << endl;
  
  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Magic Square
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			MagicSquare square = new MagicSquare(n);
			System.out.print(square.toString());
		}
	}

}

class MagicSquare {
	private int n;
	private int[][] square;

	MagicSquare(int n) {
		this.n = n;
		square = new int[n][n];
		generate();
	}

	private void generate() {
		int max = n * n + 1;
		Index idx = null;

		idx = first();
		setValue(1, idx);
		for (int i = 2; i < max; i++) {
			idx = next(idx);
			setValue(i, idx);
		}
	}

	private Index first() {
		int x = n / 2 + 1;
		int y = n / 2;
		return new Index(x, y);
	}

	private Index next(Index idx) {
		++idx.x;
		++idx.y;
		correct(idx);
		return idx;
	}

	private void correct(Index idx) {

		int x, y;
		x = idx.x;
		y = idx.y;

		if (0 <= x && x < n && 0 <= y && y < n) {
			if (square[x][y] == 0) {
				return;
			} else {
				++idx.x;
				--idx.y;
			}
		} else {
			if (x >= n) { // 下
				idx.x = 0;
			} else if (y >= n) {// 右
				idx.y = 0;
			} else if (y < 0) {// 左
				idx.y = n - 1;
			}
		}
		correct(idx);
	}

	private void setValue(int value, Index idx) {
		square[idx.x][idx.y] = value;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				sb.append(String.format("%4d", square[i][j]));
				if (j == n - 1) {
					sb.append("\n");
				}
			}
		}
		return sb.toString();
	}

	private class Index {
		int x, y;

		Index(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
    a[i] -= i;
  }

  map<int, ll> mp;
  REP(i, n) mp[a[i]]++;

  ll cnt = 0;
  REP(i, n) {
    cnt += mp[-a[i]-2*i];
  }
  cout << cnt << endl;

}
























Measured memory_bytes: 27424