akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

H,W = m()

if H == 1 or W == 1:
    print(1)
    exit()

po = W * (H // 2)
if H % 2 == 1:
    po += -(-W//2)
print(po)


Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){

    int N;
    string S;
    cin >> N >> S;
    rep(i,S.size()){
        int shift = N;
        char ch = S[i];
        if (ch >= 'A' && ch <= 'Z') { // The most naive way to do this is also the simplest.
            if (ch+shift > 'Z') // will go "out of range" when shifted, solution as discussed.
                cout<< (char)(ch-26+shift);
            else cout<< (char)(ch+shift); // will not go "out of range" when shifted.
        }
    }
    
    rn 0;
    
}


Measured memory_bytes: 256
"""
N = int(input())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

import bisect

mod = int(1e9+7)

N, K = map(int,input().split())
A = list(map(int,input().split()))

A_sorted = sorted(A)


left = []
total = []
for i in range(N):
  left_i = bisect.bisect_left(sorted(A[:i+1]), A[i])
  total_i = bisect.bisect_left(A_sorted, A[i])
  left.append(left_i)
  total.append(total_i)
  
#print(left)
#print(total)

ans = 0
for i in range(N):
  ans += ((K-1)*K//2 % mod) * left[i]
  ans += (K*(K+1)//2 % mod) * (total[i] - left[i])
  ans = ans % mod
  
print(ans)

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main () {
	int W,H,x,y,r,a,b,c,d;
	cin>>W>>H>>x>>y>>r;
	a=x-r;
	b=x+r;
	c=y-r;
	d=y+r;
	if (a<0){
	cout<<"No"<<endl;
	}else if(W<b){
	cout<<"No"<<endl;
	}else if(0<=a&&b<=W&&0<=c&&d<=H){
	cout<<"Yes"<<endl;
	}else if(c<0){
	cout<<"No"<<endl;
	}else if(H<d){
	cout<<"No"<<endl;
	}
	return 0;
}


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

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  ll iterA = 0;
  ll iterB = 0;
  ll ans = 0;
  while (a[iterA] <= k) {
    k -= a[iterA];
    iterA++;
    // cout << iterA << ":" << iterB << ":k=" << k << endl;

    if (iterA == n) break;
  }

  while (b[iterB] <= k) {
    k -= b[iterB];
    iterB++;
    // cout << iterA << ":" << iterB << ":k=" << k << endl;

    if (iterB == m) {
      cout << iterA + iterB << endl;
      return 0;
    }
  }

  ans = iterA + iterB;

  for (; iterA > 0; iterA--) {
    k += a[iterA - 1];
    while (b[iterB] <= k) {
      k -= b[iterB];
      iterB++;
      if (iterB == m) break;
    }
    // cout << iterA << ":" << iterB << ":k=" << k << endl;
    ans = max(iterA - 1 + iterB, ans);
    if (iterB == m) break;
  }

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

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
import copy
import collections

def calc(k, balls):
    dif = len(set(copy.copy(balls))) - int(k)
    change_count = 0

    if dif <= 0:
        return change_count
    else:
         c = collections.Counter(balls)
         most_common = c.most_common()[::-1]
         for x in most_common:
             change_count = change_count +  x[1]
             dif = dif - 1
             if dif <= 0 :
                break
         return change_count


_ = input().split()
k = _[1]
balls = sorted(input().split())

print(calc(k, balls))


Measured memory_bytes: 53828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    if(s[s.size()-1]=='s')cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
 
#define max_v 100010
 
using namespace std;
 
int dfnum[max_v];
int vertex[max_v];
int parent[max_v];
int ancestor[max_v];
int idom[max_v];
int semi[max_v];
int samedom[max_v];
int best[max_v];
vector<int>bucket[max_v];
 
vector<int>G[max_v],rG[max_v];
 
void dfs(int p, int n,int &k){
  if(dfnum[n]==0 && !(n==0 && p>0)){
    dfnum[n]=k;
    vertex[k++]=n;
    parent[n]=p;
    for(int i=0;i<G[n].size();i++){
      dfs(n,G[n][i],k);
    }
  }
}
 
int ancestorWithLowestSemi(int v){
  int a=ancestor[v];
  if(ancestor[a]>0){
    int b=ancestorWithLowestSemi(a);
    ancestor[v]=ancestor[a];
    if(dfnum[semi[b]] < dfnum[semi[best[v]]])best[v]=b;
  }
  return best[v];
}
 
void link(int p,int n){
  ancestor[n]=p;
  best[n]=n;
}
 
void dominator(int sz,int root){
  for(int i=0;i<sz;i++){
    bucket[i].clear();
    dfnum[i]=semi[i]=ancestor[i]=idom[i]=samedom[i]=0;
  }
 
  int N=0;
  dfs(0,root,N);
   
  for(int i=N-1;i>0;i--){
    int n=vertex[i],p=parent[n],s=p;
    for(int j=0;j<rG[n].size();j++){
      int v=rG[n][j],s1;
      if(dfnum[v]<=dfnum[n])s1=v;
      else s1=semi[ancestorWithLowestSemi(v)];
       
      if(dfnum[s1]<dfnum[s])s=s1;
    }
    semi[n]=s;
    bucket[s].push_back(n);
    link(p,n);
    for(int j=0;j<bucket[p].size();j++){
      int v=bucket[p][j],y=ancestorWithLowestSemi(v);
      if(semi[y]==semi[v])idom[v]=p;
      else samedom[v]=y;
    }
    bucket[p].clear();
  }
 
  for(int i=1;i<N;i++){
    int n=vertex[i];
    if(samedom[n]>0){
      idom[n]=idom[samedom[n]];
    }
  }
 
  for(int i=1;i<N;i++){
    for(int j=0;j<rG[i].size();j++){
      if(rG[i][j]==root)idom[i]=0;
    }
  }
}
 
int main(void){
 
  int n,m;
  cin >> n >> m;
 
  for(int i=0;i<m;i++){
    int s,t;
    cin >> s >> t;
    s--,t--;
    G[s].push_back(t);
    rG[t].push_back(s);
  }
 
  dominator(n,0);
 
  int q,r;
  cin >> q;
  while(q--){
    cin >> r;
    r--;
    if(idom[r]==0)cout << r+1 << endl;
    else cout << idom[r]+1 << endl;
  }
 
  return 0;
}


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

int seg[26][SEG_LEN * 2];

void add(int cha, int ind, int v){
    ind += SEG_LEN;
    seg[cha][ind] += v;
    while(true){
        ind /= 2;
        if(ind == 0)break;
        seg[cha][ind] = seg[cha][ind * 2] + seg[cha][ind * 2 + 1];
    }
}

int sum(int cha, int l, int r){
    l += SEG_LEN;
    r += SEG_LEN;
    int ans = 0;
    while(l < r){
        if(l % 2 == 1){
            ans += seg[cha][l];
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            ans += seg[cha][r-1];
            r--;
        }
        r /= 2;
    }
    return ans;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,q;
  string s;
  cin >> n >> s >> q;
  rep(i,n){
    add(s[i]-'a',i+1,1);
  }
  rep(j,q){
    int id;
    cin >> id;
    if(id==1){
      int i;
      char c;
      cin >> i >> c;
      add(s[i-1]-'a',i,-1);
      add(c-'a',i,1);
      s[i-1]=c;
    }else{
      int ans=0;
      int l,r;
      cin >> l >> r;
      rep(k,26){
        if(sum(k,l,r+1))ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 159772
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        # 始点ノードidx，終点ノードidx，容量をinput
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        # source/targetノードのidxを入力すると最大フロー（＝最小カット）が出力
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

N = int(input())
a = [0] + list(map(int, input().split()))

dinic = Dinic(N+2)

for i in range(1,N+1):
    x = a[i]
    if x >= 0:
        dinic.add_edge(0, i, 0)
        dinic.add_edge(i, N+1, x)
    else:
        dinic.add_edge(0, i, abs(x))
        dinic.add_edge(i, N+1, 0)

for i in range(1,N+1):
    for j in range(2,N//i + 1):
        dinic.add_edge(i, j*i, INF)

print(sum([max(aa,0) for aa in a]) - dinic.flow(0, N+1))

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

int main() {
	//受け取り、前処理など
	long N;
	cin >> N;
	vector<pair<long, long>> V(N);
	for (long i = 0; i < N; i++){
		long a;
		cin >> a;
		V.at(i) = make_pair(a, i + 1);
	}
	sort(V.begin(), V.end());
//ペアを受け取り、片方でソート
	//set
	long ans = 0;
	std::multiset<long> S;
	S.insert(0);
	S.insert(0);
	S.insert(N + 1);
	S.insert(N + 1);
	for (long i = 0; i < N; i++){
		long num = V.at(N - 1 - i).second;
		decltype(S)::iterator r = S.lower_bound(num);
		auto s = r;
		s++;
		auto p = r;
		p--;
		p--;
		auto q = r;
		q--; 
		S.insert(num);
		ans += ((*r - num) * (*q - *p) + (*s - *r) * (num - *q)) * (N - i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
int wa(int aa){
  int sum=0;
  while(1){
    sum=sum+aa%10;
    aa=aa/10;
    if(aa==0)
      break;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  int a,b,waa;
  int min=1000000;
  for(int i=1;i<n;i++){
    a=i;b=n-i;
    waa=wa(a)+wa(b);
    if(waa<min){
      min=waa;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#include <bits/stdc++.h>
using namespace std;

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

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  int N;
  
  cin >> N;
  
  double P=0;
  
  if(N%2==0){
    P=0.5;
  }
  else
  {
    P=((double)N+1)/((double)N*2);
  }
  
  cout << fixed;
  cout << setprecision(15) << P << endl; 

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}




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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 300010, M = 2 * N, mod = 1e9 + 7;

int n, m, k;
int h[N], e[M], w[M], ne[M], idx;
LL dist[N];
bool st[N];
priority_queue<PII, vector<PII>, greater<PII>> heap;

void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void Dijkstra(int root)
{
	memset(dist, 0x3f, sizeof dist);
	dist[root] = 0;
	heap.push({dist[root], root});
	
	while (heap.size())
	{
		auto t = heap.top();
		heap.pop();
		
		int v = t.S, d = t.F;
		st[v] = true;
		
		for (int i = h[v]; ~i; i = ne[i])
		{
			int j = e[i];
			if (dist[j] > dist[v] + w[i])
			{
				dist[j] = dist[v] + w[i];
				heap.push({dist[j], j});
			}
		}
	}
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		add(a, b, c), add(b, a, c);
	}
	
	scanf("%d%d", &m, &k);
	Dijkstra(k);
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%lld\n", (LL)dist[a] + (LL)dist[b]);
	}
    return 0;
}


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


int main() {
    int a,b,c;
    cin>>a>>b>>c;   
    int flag=0;
    if(a==b && b!=c) flag=1;
    if(b==c && c!=a) flag=1;
    if(c==a && a!=b) flag=1;

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

    return 0;
}


Measured memory_bytes: 256
k, a, b = gets.split.map(&:to_i)

result = if k == 1
           2
         elsif a >= b - 1 || k - 1 < a
           1 + k
         else
           bump = a - 1
           change = (k - bump) / 2
           bump += (k - bump) % 2
           1 + bump + change * (b - a)
         end
puts result


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct shop { ll a; ll b; };

int main() {
  ll N, T; cin >> N >> T;
  vector<shop> sh;
  vector<ll> a_zero;
  rep(i,N) { 
    ll a, b; cin >> a >> b; 
    if (a!=0) sh.push_back({a,b});
    else a_zero.push_back(b);
  }
  sort(all(sh),[](const shop &x, const shop &y){return x.a*(y.b+1)>(x.b+1)*y.a;});
  sort(all(a_zero));
  rep(i,a_zero.size()) a_zero[i] += i==0 ? 1 : a_zero[i-1]+1;

  // for (auto x: sh) cout << x.a << "-" << x.b << " "; cout << endl;
  // debug(all(a_zero));
  
  int s = sh.size();
  ll dp[s+1][32] = {}; rep(i,s+1) fill_n(dp[i]+1,31,INF);
  rep(i,s) {
    repr(j,1,32) {
      dp[i+1][j] = min(T+1,min(dp[i][j], (dp[i][j-1]+1)*(sh[i].a+1)+sh[i].b));
    }
  }
  // rep(i,s+1) debug(dp[i],dp[i]+min(30,s+1));

  int result = 0;
  rep(i,32) {
    if (dp[s][i]>T) continue;
    int pos = upper_bound(all(a_zero),T-dp[s][i])-a_zero.begin();
    // cout << i << " " << pos << endl;
    result = max(result,i+pos);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 53980
#include <iostream>

using namespace std;

typedef long long ll;
ll n, k, cnt[50], K[50], ans;

int main()
{
	cin >> n >> k;
	ll kk = k;
	while (kk > 0)
	{
		K[0]++;
		if (kk % 2 == 1) K[K[0]] = 1;
		kk /= 2;
	}
	//for (int i = K[0]; i >= 1; i--) cout << K[i];
	for (ll i = 1; i <= n; i++)
	{
		ll x;
		cin >> x;
		ll now = 0;
		while (x > 0)
		{
			now++;
			if (x % 2 == 1)
			{
				cnt[now]++;
			}
			x /= 2;
		}
	}
	for (int i = 45; i >= 1; i--)
	{
		ans *= 2;
		ans += (K[i]? n - cnt[i]:cnt[i]);
	}
	for (int i = 1; i <= 45; i++)
	{
		if (K[i] == 1)
		{
			ll now = 0;
			for (int j = 45; j > i; j--)
			{
				now *= 2;
				now += (K[j]? n - cnt[j]: cnt[j]);
			}
			now *= 2;
			now += cnt[i];
			for (int j = i - 1; j >= 1; j--)
			{
				now *= 2;
				now += max(n - cnt[j], cnt[j]);
			}
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ,t  ;
	cin >> n >> t ;
	vi a(n),b(n);
	t--;
	rep(i,0,n){
		cin >> a[i] >> b[i];
	}
	int ans = 0 ;
	vi idx(n);
	iota(all(idx),0);
	auto cmp = [&](int i , int j){return a[i] < a[j];};
	sort(all(idx),cmp);
//	trace(idx);
	vi dp(t+1,-MOD);
	dp[0]=0;
	trav(i,idx){
		ans = max(ans,b[i]+*max_element(all(dp)));
		vi newdp = dp;
	//	trace(dp,newdp);
		for(int j = a[i] ; j < t+1 ; ++j){
			newdp[j] = max(newdp[j],dp[j-a[i]]+b[i]);
		}
		dp = newdp;
//		swap(newdp,dp);
	}
	cout << ans << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3748
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<stack>
using namespace std;

int main(){

    stack<int> S;
    string str;
    getline(cin, str);

    bool flag = false;
    int num = 0;
    for(int i=0; i<str.length(); i++){
        if((str[i]>='0')&&(str[i]<='9')){
            flag = true;
            num = num*10 + (str[i]-'0'); //うまい！
        }else {
            if(flag == true){
            S.push(num);
            num = 0;
            flag = false;
            }
        else if(str[i]=='+'){
            int a, b;
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }else if(str[i]=='-'){
            int a, b;
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b-a);
        }else if(str[i]=='*'){
            int a, b;
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);   
            }
        }
    }
    int ans = S.top();
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
	for (unsigned i = 0; i < v.size(); i++)
		in >> v[i];
	return in;
}


void solve(){
		lo N; cin>>N;
		lo n = ceil((double)sqrt(N));
		lo count = 0;
		vl dp(N+1,0);
		for(int i = 1;i<n;i++)
		{
			for(int j = 1;j<n;j++){
				for(int k = 1;k<n;k++){
					lo x = i*i + j*j + k*k + i*j + j*k + k*i;
					if(x<=N)
					 dp[x]++;
				}
			}
		}
		for(int i = 1;i<=N;i++)cout<<dp[i]<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(20);
	solve();
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

char a[11][11];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,q; cin>>n>>m>>q;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<(1<<m);j++)
		{
			int cnt=0;
			for(int k=0;k<n;k++)
			{
				for(int l=0;l<m;l++)
				{
					if(i&(1<<k)) continue;
					if(j&(1<<l)) continue;
					if(a[k][l]=='#') cnt++;
				}
			}
			if(cnt==q) ans++;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3648
//smtb2019_e.cpp
//Sun Dec  1 20:57:22 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
ll MOD = 1000000007;

int main(){
	ll n;
	cin >> n;

	ll a[n];
	ll color[3];
	color[0] = 0;
	color[1] = 0;
	color[2] = 0;
	ll ans = 1;
	for (int i=0;i<n;i++){
		cin >> a[i];
		ll temp = 0;
		ll index = -1;
		for (int j=0;j<3;j++){
			if (color[j]==a[i]){
				temp++;
				index = j;
			}
		}
		if (index==-1){
			cout << 0 << endl;
			return 0;
		}
		ans = ans*temp%MOD;
//		cout << index << endl;
		color[index]++;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

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

long long calc(ll a, ll b, ll p){
    if(b == 0) return 1;
    if(b % 2 == 0){
        long long d = calc(a, b/2, p)%p;
        return (d*d)%p;
    }else{
        return (a*calc(a, b-1, p))%p;
    }
}
long long comb(ll n, ll r) {
    const ll MOD = 1e9+7;
    long long sum = 1;
    for(ll i=n;i>n-r;i--) sum = (sum*i)%MOD;
    for(ll i=r;i>0;i--) sum = (sum*calc(i, MOD-2, MOD)%MOD)%MOD;
    return sum;
}

int main() {
    cin >> X >> Y;
    ll rank = (X+Y)/3;
    if((X+Y)%3 != 0) cout << 0;
    else if(abs(X-Y) > (X+Y)/3) cout << 0; 
    else cout << comb(rank, rank/2-abs(X-Y)/2);
}


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

#define getn int n; cin >> n
#define fori(n) for (int i = 0; i < (n); i++)
#define forj(n) for (int j = 0; j < (n); j++)
#define forifill(n,x) for (int i = 0; i < (n); i++) cin >> x[i]
#define foriprint(n,x) for (int i = 0; i < (n); i++) cout << x[i] << " "
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define unsync cin.sync_with_stdio(false), cin.tie(0)
#define inoutfile freopen("d:\\testcase.txt", "r", stdin);freopen("d:\\output.txt", "w", stdout)

typedef unsigned long long lng;


int main()
{
	unsync;

	int x[3];
	cin >> x[0] >> x[1] >> x[2];
	sort(x, x + 3);
	cout << ((x[0] == x[1] && x[0] == 5 && x[2] == 7) ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2020/03/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    vi a(n);
    vl count(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
        count[a[i]]++;
    }
    ll ans = 0;
    rep(i, n){
        ans += count[i] * (count[i] - 1) / 2;
    }
    rep(i, n){
        cout << ans - count[a[i]] * (count[a[i]] - 1) / 2 + (count[a[i]] - 1) * (count[a[i]] - 2) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
S = input()
ans = 0
hand = ['g', 'p']

def do(s, t):
  if s == t:
    return 0
  elif s == 'g':
    return 1
  else:
    return -1

for i, s in enumerate(S):
  ans += do(s, hand[i%2])

print(ans)

Measured memory_bytes: 3316
// https://atcoder.jp/contests/abc167/tasks/abc167_b

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define int long long
#define all(x) (x).begin(), (x).end()

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;

    int take = min(a, k);
    a -= take;
    k -= take;
    ans += take;

    take = min(b, k);
    b -= take;
    k -= take;

    take = min(c, k);
    c -= take;
    ans -= take;

    cout << ans << endl;
}


Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int N,K,T,U,V,L;
int carrot[100010];
int down[100010];

int main(){
    while(cin >> N >> K >> T >> U >> V >> L){
        rep(i,L+1) carrot[i] = down[i] = 0;
        rep(i,N){
            int D; cin >> D;
            carrot[D] = 1;
        }
        int have = 0;
        double ans = 0;
        int rem = 0;
        loop(i,1,L+1){
            if(rem) ans += 1./V;
            else ans += 1./U;
            if(rem) rem--;
            if(have && !rem){
                have--;
                rem = V*T;
            }
            if(carrot[i]){
                if(!rem){
                    carrot[i]--;
                    rem = V*T;
                }
                if(have + carrot[i] > K){
                    carrot[i]--;
                    rem = V*T;
                    have = K;
                } else {
                    have+=carrot[i];
                }
            }
        }
        printf("%.10lf\n", ans);
    }
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,C,D,N;
  cin>>A>>B>>C>>D>>N;
  A=min({4*A,2*B,C});
  if(N%2==0)cout<<min(N*A,N/2*D)<<endl;
  else cout<<min(N*A,(N-1)/2*D+A)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int sol = 0;
        for (int i = 0; i < N; i++) {
            if (sc.nextInt() >= K) sol++;
        }

        System.out.println(sol);
    }
}


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

int main() {
  int a,b;
  cin >> a >> b;
  a = a%3;
  b = b%3;
  if(a == 0||b==0||a+b==3){
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let X = read::<i32>();
    let Y = read::<i32>();
    let Z = read::<i32>();
    let n = (X-Z)/(Y+Z);
    println!("{}", n);

}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i<n;i++) cin >> a.at(i);
    int b = 0;
    vector<int> ans(n);
    for(int i :a) b ^= i;
    for(int i:a) cout << (i^b) << " ";
    cout << endl;
}

Measured memory_bytes: 4752
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-2):
    for j in range(i+1, n-1):
        if 2*j - i >= n:
            break
        elif s[i] != s[j] and s[j] != s[(2*j-i)] and s[(2*j-i)] != s[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <math.h>
using namespace std;

int main(){
        unsigned long long N;
        cin >> N;
        int i,a,b=0;
        int ans1,ans2;
        for(i=1; i<=sqrt(N); i++) {
                if(N%i==0) {
                        ans1 = i;
                        ans2 = N/i;
                }
        }
        if(ans1>ans2) {
                a=ans1;
        }else{
                a=ans2;
        }
        while(a>0) {
                a /=10;
                b++;
        }
        cout << b << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int a,b;
cin >> a >> b;
b = 2*b;
if(a>b){
    cout << a-b << endl;
}
else{
    cout << 0 << endl;
}
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;

fn main() {
    input!{n:usize, m:usize, x:[i64;m]};
    if m as i64 - n as i64 <= 0 { println!("0"); return(); }
    let mut x = x;
    x.sort();
    let mut d = vec![];
    for i in 0..m-1 {
        d.push((x[i]-x[i+1]).abs())
    }
    d.sort();
    //debug!(d);
    println!("{}", d.iter().take(m - n).sum::<i64>());

}

Measured memory_bytes: 6396
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto cnt = N / K;
	auto ans = cnt^^3;
	if (K % 2 == 0)
	{
		auto cnt2 = (N+K/2) / K;
		ans += cnt2^^3;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] count = line.split(" ");
		int a = Integer.parseInt(count[0]);
		int b = Integer.parseInt(count[1]);

		System.out.print((a / b) + " ");
		System.out.print((a % b) + " ");

		double c = (double) a / (double) b;

		System.out.printf("%5f",  c);
	}

}


Measured memory_bytes: 26356
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x := getNextInt(scanner)
	fmt.Fprintln(writer, 1-x)
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s==u)
  cout << a-1 << " " << b << endl;
  else
  cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, x, l, ans = 0;cin >> n;
	vector<pair<int, int>> p(n);
	rep(i, n) {
		cin >> x >> l;
		p[i] = make_pair(x + l,x - l);
	}
	sort(p.begin(), p.end());
	int a = -(1 << 30);
	rep(i, n) {
		if (p[i].second >= a) {
			ans++;
			a = p[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
# sys.setrecursionlimit(100000)
from collections import deque


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S_deq = deque(list(input()))
    cnt = 0
    while S_deq:
        # 残り1文字のとき
        if len(S_deq) == 1:
            S_deq.pop()
        # 両端が同じ文字のとき
        elif S_deq[0] == S_deq[-1]:
            S_deq.popleft()
            S_deq.pop()
        # 片方が x のとき
        elif S_deq[0] == "x":
            S_deq.popleft()
            cnt += 1
        elif S_deq[-1] == "x":
            S_deq.pop()
            cnt += 1
        else:
            print(-1)
            return
    print(cnt)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 80196
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(M * 2);
  for (int i = 0; i < M; i++) {
    cin >> v[i * 2] >> v[i * 2 + 1];
  }
  for (int i = 0; i < N; i++) {
    cout << count(v.begin(), v.end(), i + 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll A, B, K;
    cin >>A >> B >> K;
    if(A >= K){
        A -= K;
        K = 0;
    }
    else{
        K -= A;
        A = 0;
    }
    if(B >= K){
        B -= K;
        K = 0;
    }
    else{
        K -= B;
        B = 0;
    }
    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, K;
vector<pii > V;

signed main(){
    cin >> N >> K;
    int sum = (N - 2) * (N - 1) / 2;
    if(K > sum){
        printf("-1\n");
        return 0;
    }
    int M = 0;
    for(int i = 2; i <= N; i++){
        V.push_back(mk(1, i));
        M++;
    }
    for(int i = 2; i <= N; i++){
        for(int j = i + 1; j <= N; j++){
            if(sum > K){
                M++;
                V.push_back(mk(i, j));
                sum--;
            }
        }
    }
    printf("%lld\n", M);
    for(int i = 0; i < M; i++){
        printf("%lld %lld\n", V[i].first, V[i].second);
    }

    return 0;
}
/*


*/

Measured memory_bytes: 512
def sumdigit(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n //= 10
    return ans

N, A, B = [int(x) for x in input().split()]

ans = 0
for i in range(1, N + 1):
    sd = sumdigit(i)
    if A <= sd and sd <= B:
        ans += i

print(ans)


Measured memory_bytes: 2940
n = $stdin.gets.to_i
array = (1..n).map { $stdin.gets.chomp }
array = array.map{|s|s.chars.sort.join}
map = array.inject(Hash.new(0)){|h,e|h.tap{|hh|hh[e]+=1}}

sum = 0
map.each_pair do |s, cnt|
  sum += (1..cnt-1).to_a.inject(:+).to_i
end
puts sum


Measured memory_bytes: 36988
#include <cstdio>

char st[99];
int main() {
	scanf("%s",st);
	for(int i=0;i<4;i++) printf("%c",st[i]);
	printf(" ");
	for(int i=4;i<12;i++) printf("%c",st[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
int main() {
	int n;
	cin >> n;
	string s1, s2;
	vector<int> state;
	cin >> s1 >> s2;
	rep(i, 0, n) {
		if (s1[i] == s2[i]) {
			state.push_back(1);
		}
		else {
			state.push_back(0);
			i++;
		}
	}
	ll ans = 1;
	rep(i, 0, state.size()) {
		if (i == 0) {
			if (state[i])ans *= 3;
			else ans *= 6;
		}
		else {
			if (state[i - 1])ans *= 2;
			else if (state[i] == 0)ans *= 3;
		}
		ans %= 1000000007;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
D, N = map(int, input().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(100*N)
elif D == 2:
    if N == 100:
        print(1010000)
    else:
        print(10000*N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long flag;
  for(int i = N; ; i++){
    flag = 1;
    for(int j = 2; j <= sqrt(N); j++){
      if(i % j == 0){
        flag = 0;
        break;
      }
    }
    if(flag == 1){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256