akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; ll m; cin >> n >> m;
    vll a(n); for(auto& e : a) cin >> e, e %= m;

    vll sum(n+1);
    ll res = 0LL;
    map<ll, int> hist;
    hist[0]++;
    rep(i, n){
        sum[i+1] = ADD(sum[i], a[i], m);
        res += hist[sum[i+1]];
        hist[sum[i+1]]++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(c-b>a){
		cout<<"dangerous"<<endl;
	}
	else if(c<=b){
		cout<<"delicious"<<endl;
	}
	else{
		cout<<"safe"<<endl;
	}
}


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

def resolve():
    count = 0
    ans = "No"
    for i in range(N):
        A = input().split()
        if A[0] == A[1]:
            count += 1
            if count == 3:
                ans = "Yes"
                return ans
        else:
            count = 0
    return ans
print(resolve())

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll k, q;
ll d[5010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> k >> q;
    for(int i = 1; i <= k; i++){
        cin >> d[i];
    }
    for(int i = 0; i < q; i++){
        ll n, x, m;
        cin >> n >> x >> m;
        n--;
        ll ans = n;
        ll sum = x;
        for(int j = 1; j <= k; j++){
            ll md = d[j] % m;
            sum += md * (n / k);
            if(md == 0) ans -= n / k;
            if(n % k >= j) sum += md;
            if(md == 0 && n % k >= j) ans--;
        }
        cout << ans - (sum / m) + (x / m) << endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int w[10],k[10];

int main(){
	cin.sync_with_stdio(false);
	rep(i,10)cin>>w[i];
	rep(i,10)cin>>k[i];
	sort(w,w+10,greater<int>()); sort(k,k+10,greater<int>());
	int res=0,resb=0;
	rep(i,3)res+=w[i];
	rep(i,3)resb+=k[i];
	cout<<res<<" "<<resb<<endl;
	return 0;
}

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

#define N 100000

int main(void){
    vector<bool> prime(N+1,true);
    prime[0]=prime[1]=false;
    for (size_t i = 2; i*i <= N; i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likeCnt[N];
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1]+(i%2==1&&prime[i]&&prime[(i+1)/2]);
    }
    /**************************************/
    int q;
    scanf("%d", &q);
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", likeCnt[r] - likeCnt[l-1]);
    }
    return 0;
}

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

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define rep(i, n) for(LL i = 0; i < n; i++)

string S;

void input()
{
  cin >> S;
}

void solve()
{
  int rmCnt = 0;

  bool proc = true;
  while(proc && 1 < S.length())
  {
    proc = false;
    rep(i, S.length()-1)
    {
      if(S[i] != S[i+1])
      {
//        cout << S[i] << " " << S[i+1] << endl;
        S.erase(i, 2);
//        cout << S << endl;
        rmCnt++;
        proc = true;
        break;
      }
    }
  }

  cout << rmCnt*2;
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  int one_count = 0;
  for (int i = 0; i < 3; i++) {
  	if (s.at(i) == '1') {
      one_count++;
    }
  }
  cout << one_count << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline

S = deque(input()[:-1])
reverse_flg = 0
Q = int(input())
qs = [input().split() for _ in range(Q)]
for q in qs:
    if q[0] == '1':
        reverse_flg = reverse_flg ^ 1
    else:
        flg = (int(q[1]) + reverse_flg) % 2
        if flg == 1:
            S.appendleft(q[2])
        else:
            S.append(q[2])

if reverse_flg:
    S.reverse()
print(''.join(S))


Measured memory_bytes: 133500
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int h[300000], a[300000];
int dp[300000];
int dat[300000];
void update(int x, int y) {
	while (x <= n) {
		chmax(dat[x], y);
		x += x & -x;
	}
}
int query(int x) {
	int res = 0;
	while (x > 0) {
		res = max(res, dat[x]);
		x -= x & -x;
	}
	return res;
}
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> h[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dp[i] = query(h[i] - 1) + a[i];
		update(h[i], dp[i]);
		chmax(ans, dp[i]);
	}
	cout << ans << endl;
}

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


int main() {

    ll n;
    cin >> n;
    ll ans = 1e18;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i != 0) continue;
        ll j = n / i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// File name: 8 Puzzle
// Written by: by_sknight
// Date: 2019/5/21
#include <bits/stdc++.h>
using namespace std;
#define size 3


struct Board {
	int P[size][size];
	int space_x, space_y;
	bool up() {
		if (space_y == 0) {
			return false;
		}
		swap(P[space_x][space_y], P[space_x][space_y - 1]);
		space_y--;
		return true;
	}
	bool down() {
		if (space_y == size - 1) {
			return false;
		}
		swap(P[space_x][space_y], P[space_x][space_y + 1]);
		space_y++;
		return true;
	}
	bool left() {
		if (space_x == 0) {
			return false;
		}
		swap(P[space_x][space_y], P[space_x - 1][space_y]);
		space_x--;
		return true;
	}
	bool right() {
		if (space_x == size - 1) {
			return false;
		}
		swap(P[space_x][space_y], P[space_x + 1][space_y]);
		space_x++;
		return true;
	}
	bool isOver() {
		int i, j, v;
		v = 1;
		for (i = 0; i < size; i++) {
			for (j = 0; j < size; j++) {
				if (i == size - 1 && j == size - 1) {
					return true;
				}
				if (P[i][j] != v)
					return false;
				v++;
			}
		}
		return true;
	}
	void operator=(const Board& obj) {
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				P[i][j] = obj.P[i][j];
			}
		}
		space_x = obj.space_x;
		space_y = obj.space_y;
	}
	bool operator<(const Board& obj) const{
		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				if (P[i][j] < obj.P[i][j])
					return true;
				else if (P[i][j] > obj.P[i][j])
					return false;
			}
		}
		return false;
	}
};

set<Board> status;
Board bo;

void solution() {
	queue<pair<Board, int> > Q;
	Board now_board;
	int now_step;
	Q.push(make_pair(bo, 0));
	while (1) {
		now_board = Q.front().first;
		now_step = Q.front().second;
		Q.pop();
		// 如果满足最终条件, 退出循环
		if (now_board.isOver()) {
			break;
		}
		// 如果当前棋盘状态已经出现过, 则直接跳过, 处理下一个
		if (status.insert(now_board).second == false) { 
			continue;
		}
		// 如果可以向上移动空格, 则将向上移动之后的状态与步数存入队列
		if (now_board.up()) {
			Q.push(make_pair(now_board, now_step + 1));
			// 之后恢复之前的状态
			now_board.down();
		}
		// 以下三个同上
		if (now_board.down()) {
			Q.push(make_pair(now_board, now_step + 1));
			now_board.up();
		}
		if (now_board.left()) {
			Q.push(make_pair(now_board, now_step + 1));
			now_board.right();
		}
		if (now_board.right()) {
			Q.push(make_pair(now_board, now_step + 1));
			now_board.left();
		}
	}
	while (!Q.empty()) {
		Q.pop();
	}
	cout << now_step << endl;
	return;
}

int main(void) {
	for (int i = 0; i < size; i++) {
		for (int j = 0; j < size; j++) {
			cin >> bo.P[i][j];
			if (bo.P[i][j] == 0) {
				bo.space_x = i;
				bo.space_y = j;
			}
		}
	}
	solution();
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

    ll n,k; cin>>n>>k;

    if(n < k){
        cout<<min(n, k-n)<<endl;
        return 0;
    }
    cout<<min(n%k, abs(n%k - k))<<endl;

    return 0;

}

Measured memory_bytes: 256
N, K = map(int, input().split())
best = [0] * N
not_best = []
for _ in range(N):
    t, d = map(int, input().split())
    if best[t-1] != 0:
        not_best.append(min(d, best[t-1]))
    best[t-1] = max(d, best[t-1])
best = [x for x in best if x != 0]
best.sort(reverse=True)
not_best.sort(reverse=True)
acc_best = [0] * (N + 1)
acc_not_best = [0] * (N + 1)
for i in range(len(best)):
    acc_best[i+1] = acc_best[i] + best[i]
for i in range(len(not_best)):
    acc_not_best[i+1] = acc_not_best[i] + not_best[i]
cand = []
for x in range(1, K+1):
    if x > len(best):
        break
    if K - x > len(not_best):
        continue
    cand.append(acc_best[x] + acc_not_best[K-x] + x**2)
print(max(cand))

Measured memory_bytes: 14224
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <functional>
using namespace std;

struct data{
	int t,id,id_park,type;
	data(){}
	data(int tt,int ii,int dd,int ttt){
		t=tt;
		id=ii;
		id_park=dd;
		type=ttt;
	}
	bool operator<(const data &d1)const{
		if(t==d1.t){
			if(type!=d1.type)return type<d1.type;
			if(type==0)return id>d1.id;
			return id_park>d1.id_park;
		}
		return t>d1.t;
	}
};

int m,n;
int t[120];
int res[120];
int park[11][2];

data park_car(data x){
	data res=x;
	res.type=-1;
	res.t+=t[x.id];
	for(int i=0;i<m;i++){
		if(park[i][1]==-1){
			res.id_park=i*2+1;
			res.type=1;
			return res;
		}
	}
	int id=-1;
	for(int i=0;i<m;i++){
		if(park[i][0]==-1){
			if(park[i][1]>=res.t){
				if(id==-1)id=i;
				else if(park[id][1]>park[i][1])id=i;
			}
		}
	}
	if(id!=-1){
		res.id_park=id*2;
		res.type=1;
		return res;
	}
	for(int i=0;i<m;i++){
		if(park[i][0]==-1){
			if(id==-1)id=i;
			else if(park[id][1]<park[i][1])id=i;
		}
	}
	if(id!=-1){
		res.id_park=id*2;
		res.type=1;
	}
	return res;
}

int main(void){
	while(1){
		scanf("%d%d",&m,&n);
		if(m+n==0)break;
		priority_queue<data> que;
		for(int i=0;i<n;i++){
			scanf("%d",&t[i]);
			que.push(data(i*10,i,-1,0));
		}
		memset(park,-1,sizeof(park));
		int cnt=0;
		while(que.size()){
			data q=que.top();
			que.pop();
			if(q.type==0){
				data next=park_car(q);
				if(next.type==-1){
					q.t++;
					que.push(q);
				}else{
					park[next.id_park/2][next.id_park%2]=next.t;
					que.push(next);
				}
			}else{
				if(q.id_park%2==1 && park[q.id_park/2][0]!=-1){
					q.t++;
					que.push(q);
				}else{
					res[cnt++]=q.id;
					park[q.id_park/2][q.id_park%2]=-1;
				}
			}
		}
		for(int i=0;i<n;i++){
			printf("%d%c",res[i]+1,i==n-1?'\n':' ');
		}
	}
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long X){
    LL ans = X / 500;
    X %= 500;
    ans *= 1000;
    ans += (X / 5) * 5;
    cout << ans << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N;
    string S;
    cin >> N >> S;
    int l, r, c;
    int ans = 0;
    string s1, s2;
    for (int i = 1; i < N; i++)
    {
        if (N-i <= ans) break;
        l = 0;
        r = min(i, N-i) + 1;
        s1 = S.substr(0, i);
        while (r - l > 1)
        {
            c = (l + r) / 2;
            auto pos = s1.find(S.substr(i, c));
            if (pos == string::npos) r = c;
            else l = c;
        }
        ans = max(ans, l);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 1000123

using namespace std;

ll a, c, d;

int main() {
    ios_base::sync_with_stdio(0);

    scanf("%lld", &a);
    scanf("%lld.%lld", &c, &d);

    a;
    c *= 100;
    c += d;

    a *= c;

    a /= 100;

    printf("%lli\n", a);

    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define REP(i, k, n) for (int(i) = k; (i) <(int)(n); (i)++)
#define vi vector<int>
#define pii pair<int,int>

using ll = long long;

using namespace std;



int main(){
    int n;
    cin >> n;
    vi t(n+1), x(n+1), y(n+1);
    t[0] = x[0] = y[0] = 0;
    rep(i, n)
    {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }

    bool f = true;

    rep(i,n){
        int dt = abs(t[i + 1] - t[i]);
        int dx = abs(x[i + 1] - x[i]);
        int dy = abs(y[i + 1] - y[i]);
        //printf("%d %d %d", dt, dx, dy);

        if(dx + dy > dt or (dx+dy)%2 != dt%2)
            f = false;
    }

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


Measured memory_bytes: 1408
list = input().split()
stack = []
for i in list:
    if ( i.isdigit() ):
        stack.append(int(i))
    elif (i == '+'):
        stack.append(stack.pop() + stack.pop())
    elif (i == '*'):
        stack.append(stack.pop() * stack.pop())
    elif (i == '-'):
        stack.append( (-1)*stack.pop() + stack.pop())

print(stack.pop())

Measured memory_bytes: 7696
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

long long mod = 1e9 + 7;

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

void solve() {
	long long n;
	cin >> n;
	long long ans1 = (power(10, n) - power(9, n)) % mod;
	long long ans = ((ans1 + ans1) % mod - (power(10, n) - power(8, n) % mod)) % mod;
	if(ans < 0) ans += mod;
	cout << ans;
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main() {
	
	ll a, b, x;
	ll ans = 0;
	cin >> a >> b >> x;
	if(a != 0) a--;
	else ans++;
	ans += b/x - a/x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m,y=MI()
lis=[LI() for i in range(n)]
u=[]
point=[0 for i in range(m)]
for i in range(2**n):
    pay=0
    point=[0 for i in range(m)]
    for j in range(n):
        x=(i>>j) %2
        if x==1:
            for k in range(1,m+1):
                point[k-1]+=lis[j][k]
            pay+=lis[j][0]
    #print(min(point))
    if min(point)>=y:
        u.append(pay)
    #print(y)
if len(u)>0:
    print(min(u))
else:
    print("-1")

Measured memory_bytes: 68916
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	long long ans = 1;
	int back = 0;
	for (int i = 0;i < n;++i) {
		if (a[i] == b[i]) {
			if (back == 0) {
				ans *= 3;
				back = 1;
			}
			else if(back == 1){
				ans *= 2;
			}
			else {
				ans *= 1;
				back = 1;
			}
		}
		else {
			if (back == 0) {
				ans *= 6;
				back = 2;
			}
			else if (back == 1) {
				ans *= 2;
				back = 2;
			}
			else {
				ans *= 3;
				back = 2;
			}
			i++;
		}

		ans		%= MAX_MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
if k % 2 == 0:
    ans = 100000
    for i in range(n):
        s = [i]
        d = [-1] * n
        d[i] = 0
        while s:
            p = s.pop()
            for node in g[p]:
                if d[node] == -1:
                    s.append(node)
                    d[node] = d[p] + 1
        c = 0
        for i in range(n):
            if d[i] > k // 2:
                c += 1
        ans = min(ans, c)
else:
    ans = 100000
    for i in range(n):
        for j in g[i]:
            s = [i, j]
            d = [-1] * n
            d[i] = 0
            d[j] = 0
            while s:
                p = s.pop()
                for node in g[p]:
                    if d[node] == -1:
                        s.append(node)
                        d[node] = d[p] + 1
            c = 0
            for p in range(n):
                if d[p] > k // 2:
                    c += 1
            ans = min(ans, c)
print(ans)


Measured memory_bytes: 51032
N, X = gets.chomp.split.map(&:to_i)
L = gets.split(" ").map!{|i| i.to_i}
d = 0
for i in 0..N-1
    d += L[i]
    if d > X
        puts i + 1
        break
    end
end

if d <= X
    puts N + 1
end

Measured memory_bytes: 1788
h,w = map(int,input().split())
c = [[] for i in range(h)]
d = [[1]*w for _ in range(h)]
e = [[1]*w for _ in range(h)]
for i in range(h):
    c[i] = input()
    if c[i][0] == "#":
        d[i][0] = 0
for i in range(w):
    if c[0][i] == "#":
        e[0][i] = 0
    
for i in range(h):
    for j in range(w-1):
        if c[i][j+1] == "#":
            d[i][j+1] = 0
        else:
            d[i][j+1] = d[i][j] + 1
            
for i in range(h-1):
    for j in range(w):
        if c[i+1][j] == "#":
            e[i+1][j] = 0
        else:
            e[i+1][j] = e[i][j] + 1
            
for i in range(h):
    for j in range(w-2,-1,-1):
        if d[i][j] != 0 and d[i][j+1] != 0:
            d[i][j] = d[i][j+1]
        elif d[i][j] != 0 and d[i][j+1] == 0:
            continue
        else:
            d[i][j] = 0
            
for i in range(h-2,-1,-1):
    for j in range(w):
        if e[i][j] != 0 and e[i+1][j] != 0:
            e[i][j] = e[i+1][j]
        elif e[i][j] != 0 and e[i+1][j] == 0:
            continue
        else:
            e[i][j] = 0
            
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans , d[i][j]+e[i][j])
        
print(ans-1)

Measured memory_bytes: 125660
import java.util.*;

public class Main {
  public static void main(String[] args) {
    final String ABC_STR = "ABC";
        final String ARC_STR = "ARC";
        Scanner s = new Scanner(System.in);
        final String S = s.nextLine();

        if (ABC_STR.equals(S)) {
            System.out.println(ARC_STR);
        } else {
            System.out.println(ABC_STR);
        }
  }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll prev = 0;
    ll count = 0;
    map<ll, ll> S;
    cin >> N;
    S[0]++;
    rep(i, N) {
        ll temp;
        cin >> temp;
        prev += temp;
        S[prev]++;
    }
    iter(i, S) count += i.second * (i.second - 1) / 2;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 12800
package main

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

func main() {
	var r, c, k int
	fmt.Scan(&r, &c, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	is := make([][]int, r+1)
	for i := range is {
		is[i] = make([]int, c+1)
	}
	for i := 0; i < k; i++ {
		sc.Scan()
		y, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		is[y][x] = v
	}

	dp := make([][][]int, r+1)
	const mi = 3
	for i := range dp {
		dp[i] = make([][]int, c+1)
		for j := range dp[i] {
			dp[i][j] = make([]int, mi+1)
		}
	}
	for i := 1; i <= r; i++ {
		for j := 1; j <= c; j++ {
			for l := 0; l <= mi; l++ {
				dp[i][j][l] = max(dp[i][j][l], dp[i][j-1][l])
				dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][l])
				dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][l]+is[i][j])
				if l > 1 {
					dp[i][j][l] = max(dp[i][j][l], dp[i][j-1][l-1]+is[i][j])
				}
			}
		}
	}
	var ans int
	for l := 0; l <= mi; l++ {
		ans = max(ans, dp[r][c][l])
	}
	fmt.Println(ans)
}

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

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

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


Measured memory_bytes: 599224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int n=in();
	printf("ABC%d\n",n);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int P[70];
  int count = 0;
  for (int i=0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    if (P[i] != i + 1 ) {
      count++;
    }
  }
  if (count < 3) {
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
}

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



int main() {


  int n,y;

  cin >> n >> y;

  for(int i=0 ; 10000*i <= y && i<=n; i++){
    for(int j=0 ; 10000*i + 5000*j <= y && i+j<=n; j++){
      for(int k=0 ; 10000*i + 5000*j + 1000*k <= y && i+j+k<=n; k++){
	if(10000*i + 5000*j + 1000*k == y && i+j+k == n){
	  cout << i << ' ' << j << ' '<< k << endl;
	  return 0;
	}
      }
    }   
  }

  cout << "-1 -1 -1"<<endl;
  
  
  return 0;
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            return consoleReader.Int < 1000 ? $"ABC" : "ABD";
        }
        struct Cake
        {
            public long x; public long y; public long z;
            public static Cake operator +(Cake a, Cake b) => new Cake { x = a.x + b.x, y = a.y + b.y, z = a.z + b.z };
            public long Abs => Math.Abs(x) + Math.Abs(y) + Math.Abs(z);
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 11092
#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 ll long long int
#define ff first
#define ss second
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,
              tree_order_statistics_node_update>pbds;
//order_of_key:index number if it was there in sorted array
//find_by_order:value at 3rd index in sorted array.
const ll maxs=1e6+5;
ll root[maxs];

class cmp{
  bool operator()(const ll &a,const ll &b)
  {
      return a<b;
  }
};
void init()
{
    iota(root,root+maxs,0);
}
ll find(ll u)
{
    ll f;
    if(root[u]==u)
    return u;
    else
    {
        ll f=find(root[u]);
        root[u]=f;
        return f;
    }
}
void Union(ll x,ll y)
{
    ll u=find(x);
    ll v=find(y);
    root[v]=u;
}
ll power(ll x,ll y,ll p)
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
        res=(res*x)%p;
        
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
  

int main()
{
    ll t,n,i,k,y,x,j;
    cin>>t;
    if(t==0)
     cout<<1;
     else
     cout<<0;
    return 0;
    
}

Measured memory_bytes: 3672
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

vl divisor(ll n) {
  vl ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i, 1, n + 1) {
    if ((i & 1) == 0) continue;
    // cerr << i << endl;
    vl d = divisor(i);
    if (d.size() == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

template<typename W, typename V>
struct dijkstra_result {
	std::vector<W> distance; // 距離
	std::vector<V> prev; // 「前」の頂点
};

/**
 * ダイクストラ法で、ある頂点から到達可能な頂点までの距離と最短経路を求める
 * 
 * @tparam G 重み付きグラフの隣接集合表現の型
 *           グラフ g の頂点 u から出ている辺を for (auto& e : g.at(u)) で列挙できる型であればよい。
 * @tparam V 頂点番号の型
 * @tparam W 重みの型
 */
template<typename G, typename V, typename W = typename std::remove_reference<decltype(std::declval<G>()[0].begin()->second)>::type>
dijkstra_result<W, V> dijkstra(const G& graph, V start, V num)
{
	using PQT = std::pair<W, V>;

	std::vector<W> distance(num);
	std::vector<V> prev(num);
	std::vector<char> done(num); // 既に確定している頂点かどうか（覚えておかなくても計算できるが無駄がある）
	std::priority_queue<PQT, std::vector<PQT>, std::greater<PQT>> q;

	for (V i = 0; i < num; ++i) {
		distance[i] = std::numeric_limits<W>::max();
	}
	distance[start] = 0;
	q.push({0, start});

	while (!q.empty()) {
		const auto& du = q.top();
		const auto dist = du.first;
		const auto u = du.second;
		q.pop();
		done[u] = 1;
		const auto& edges = graph.at(u);
		for (const auto& vw : edges) {
			const auto v = vw.first;
			const auto w = vw.second;
			if (!done[v]) {
				long updated = dist + w;
				if (distance[v] > updated) {
					distance[v] = updated;
					prev[v] = u;
					q.push({updated, v});
				}
			}
		}
	}

	return {distance, prev};
}

int main()
{
	// ABC126D

	int N;
	std::vector<std::unordered_map<int, long> > E; // src -> {dst -> weight}

	std::cin >> N;
	E.resize(N);
	for (int i = 0; i < N-1; ++i) {
		int u, v;
		long w;
		std::cin >> u >> v >> w;
		--u;
		--v;
		E[u].insert({v, w});
		E[v].insert({u, w});
	}

	auto dij_res = dijkstra(E, 0, N);
	auto& D = dij_res.distance;

	for (long i = 0; i < N; ++i) {
		std::cout << (D[i] % 2) << "\n";
	}
}


Measured memory_bytes: 18688
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] a = new int[100];
		int n;
		int max = 0;
		
		while(scan.hasNextInt()){
			n = scan.nextInt();
			
			a[n-1]++;
		}
		
		for(int i = 0; i < 100; i++){
			if(a[i] > max)max = a[i];
		}
		
		for(int i = 0; i < 100; i++){
			if(a[i] == max)System.out.println(i + 1);
		}
	}
}

Measured memory_bytes: 25980
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
int nn1, dat1[12345678]; //セグメント木を持つグローバル配列
void init1(int n_) {
	nn1 = 1; while (nn1 < n_)nn1 *= 2;
	for (int i = 0; i < 2 * nn1 - 1; i++) dat1[i] = INF;
}
void update1(int k, int a) {
	k += nn1 - 1; dat1[k] = a;
	while (k > 0) { k = (k - 1) / 2; dat1[k] = min(dat1[k * 2 + 1], dat1[k * 2 + 2]); }
}
int query1(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) { return INF; }
	if (a <= l && r <= b) { return dat1[k]; }
	else {
		int vl = query1(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query1(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}
int nn2, dat2[12345678]; //セグメント木を持つグローバル配列
void init2(int n_) {
	nn2 = 1; while (nn2 < n_)nn2 *= 2;
	for (int i = 0; i < 2 * nn1 - 1; i++) dat1[i] = 0;
}
void update2(int k, int a) {
	k += nn2 - 1; dat2[k] = a;
	while (k > 0) { k = (k - 1) / 2; dat2[k] = max(dat2[k * 2 + 1], dat2[k * 2 + 2]); }
}
int query2(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) { return 0; }
	if (a <= l && r <= b) { return dat2[k]; }
	else {
		int vl = query2(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query2(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
}
int res[12345678], mi[12345678], ma[12345678], ok[12345678];
signed main() {
	int n, k, ans = 0; cin >> n >> k; init1(n); init2(n);
	vector<int> v;
	for (int h = 0; h < n; h++) {
		cin >> res[h]; update1(h, res[h]); update2(h, res[h]);
	}
	int cnt = 1;
	for (int h = 1; h < n; h++) {
		if (res[h - 1] < res[h]) { cnt++; }
		else { cnt = 1; }
		if (cnt >= k) { ok[h - k + 1] = 1; }
	}
	for (int h = 0; h <= n - k; h++) {
		if (ok[h] == 1) { ans++; continue; }
		if (query1(h, h + k, 0, 0, nn1) == res[h]) { mi[h]++; }
		if (query2(h, h + k, 0, 0, nn2) == res[h + k - 1]) { ma[h]++; }
	}
	ans = max((long long)0, ans - 1);
	for (int h = 1; h < n; h++) {
		if (mi[h - 1] == 1 && ma[h] == 1) { ans++; }
	}
	cout << n - k + 1 - ans << endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
int A[111111];


signed main(){
    cin>>N>>K;
    rep(i,N)cin>>A[i];
    int g=0;
    rep(i,N)g=__gcd(g,A[i]);
    if(K%g!=0||*max_element(A,A+N)<K)cout<<"IMPOSSIBLE"<<endl;
    else cout<<"POSSIBLE"<<endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int a,b;
	cin >> a >> b;
	cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long llong;

int R, G, B, N;
llong ans = 0;
int main()
{
	cin >> R >> G >> B >> N;

	for (int r = 0; r <= N / R; r++)
	{
		for (int g = 0; g <= (N - R * r) / G; g++)
		{
			if ((N - R * r - G * g) % B == 0)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int MOD = 998244353;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vi p(n);
	vi idx(n+1);
	rep(i,0,n) {
		cin >> p[i];
		idx[p[i]] = i;
	}
	// c[i] = a[i+1] - a[i];
	// d[i] = b[i] - b[i+1];
	vi c(n,1);
	vi d(n,1);
	rep(i,1,n) {
		int a = idx[i];
		int b = idx[i+1];
		if(a<b) {
			c[i] += b-a;
		} else {
			d[i] += a-b;
		}
	}

	vi a(n+1);
	a[1] = 1;
	rep(i,2,n+1) {
		a[i] = c[i-1] + a[i-1];
	}
	vi b(n+1);
	b[n] = 1;
	per(i,1,n) {
		b[i] = b[i+1] + d[i];
	}
	rep(i,1,n+1) {
		cout << a[i] << ' ';
	}
	cout << '\n';
	rep(i,1,n+1) {
		cout << b[i] << ' ';
	}
	return 0;
}


Measured memory_bytes: 1024
N,K = map(int,input().split())
p = list(map(int,input().split()))

S = []
for i in range(N):
    S.append(sum(range(p[i]+1))/p[i])

DP = [0 for i in range(N+1)]
SS = sum(S[:K])

for i in range(K):
    DP[i] = SS
# print(DP)
for i in range(K,N):
    DP[i] = DP[i-1]-S[i-K]+S[i]
# print(S)
# print(DP)
print(max(DP))

Measured memory_bytes: 88456